@anonymous/

FrillyTriflingMantid

Lua

No description

fork
loading
Files
  • main.lua

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.6018158668696152","path":"main.lua","file":{"path":"main.lua","content":{"asEncoding":{"base64":"LS0gU3Vic3RpdHV0ZSBmb3IgdGhlIGFjdHVhbCB0cmFuc2xhdGlvbiBmdW5jdGlvbiBqdXN0Ci0tIHJldHVybmluZyB3aGF0IGl0IGdvdC4KbG9jYWwgUyA9IGZ1bmN0aW9uICh0ZXh0LCAuLi4pCiAgcHJpbnQoJ3RleHQ6ICcuLnRleHQpCiAgZm9yIG51bWJlcix2YWx1ZSBpbiBwYWlycyhhcmcpIGRvCiAgICBwcmludCgnYXJnWycuLm51bWJlci4uJ10gPSAiJy4udmFsdWUuLiciJykKICBlbmQKZW5kCgoKbG9jYWwgU193cmFwID0gZnVuY3Rpb24gKHRleHQsIHZhcnRhYmxlKQogIC0tIFMgbmVlZHMgYSBzdHJpbmcgd2l0aCBAMSB0byBAOSBhbmQgc2luZ2xlIHZhbHVlcyBpbnN0ZWFkCiAgLS0gb2YgYSB0YWJsZS4gRmlyc3QgcGFyYW1ldGVyIGlzIHRoZSBzdHJpbmcgYW5kIHRoZSBvdGhlcgogIC0tIHZhcmlhYmxlcyBoYXZlIHRvIGJlIHRoZSBzdHJpbmdzCiAgbG9jYWwgdHJhdmVyc2FsID0ge30KICBmb3IgdmFyaWFibGUsdmFsdWUgaW4gcGFpcnModmFydGFibGUpIGRvCiAgICB0YWJsZS5pbnNlcnQodHJhdmVyc2FsLCB7dmFyaWFibGUsIHZhbHVlfSkKICBlbmQKICBmb3IgbnVtYmVyLHBheWxvYWQgaW4gcGFpcnModHJhdmVyc2FsKSBkbwogICAgbG9jYWwgdmFyaWFibGUgPSB0cmF2ZXJzYWxbbnVtYmVyXVsxXQogICAgbG9jYWwgdmFsdWUgPSB0cmF2ZXJzYWxbbnVtYmVyXVsyXQogICAgdGV4dCA9IHRleHQ6Z3N1Yih2Y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1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- Substitute for the actual translation function just
-- returning what it got.
local S = function (text, ...)
  print('text: '..text)
  for number,value in pairs(arg) do
    print('arg['..number..'] = "'..value..'"')
  end
end


local S_wrap = function (text, vartable)
  -- S needs a string with @1 to @9 and single values instead
  -- of a table. First parameter is the string and the other
  -- variables have to be the strings
  local traversal = {}
  for variable,value in pairs(vartable) do
    table.insert(traversal, {variable, value})
  end
  for number,payload in pairs(traversal) do
    local variable = traversal[number][1]
    local value = traversal[number][2]
    text = text:gsub(variable, '@'..number)
  end

  -- Hooray ... :/  
  local v1 = traversal[1] and traversal[1][2] or nil
  local v2 = traversal[2] and traversal[2][2] or nil
  local v3 = traversal[3] and traversal[3][2] or nil
  local v4 = traversal[4] and traversal[4][2] or nil
  local v5 = traversal[5] and traversal[5][2] or nil
  local v6 = traversal[6] and traversal[6][2] or nil
  local v7 = traversal[7] and traversal[7][2] or nil
  local v8 = traversal[8] and traversal[8][2] or nil
  local v9 = traversal[9] and traversal[9][2] or nil
  
  -- Call the translation function
  S(text, v1, v2, v3, v4, v5, v6, v7, v8, v9)
end


local text = '+String with +named +variables'


local parsed = S_wrap(text, {
  ['+String'] = 'Pond',
  ['+named'] = 'awesome',
  ['+variables'] = 'ducks'
})