blockly 13.0.0-beta.8 → 13.0.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lua_compressed.js CHANGED
@@ -12,115 +12,29 @@
12
12
  }
13
13
  }(this, function(__parent__) {
14
14
  var $=__parent__.__namespace__;
15
- var lists_create_empty$$module$build$src$generators$lua$lists=function(a,b){return["{}",Order$$module$build$src$generators$lua$lua_generator.HIGH]},lists_create_with$$module$build$src$generators$lua$lists=function(a,b){var c=Array(a.itemCount_);for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,Order$$module$build$src$generators$lua$lua_generator.NONE)||"nil";return["{"+c.join(", ")+"}",Order$$module$build$src$generators$lua$lua_generator.HIGH]},lists_repeat$$module$build$src$generators$lua$lists=
16
- function(a,b){var c=b.provideFunction_("create_list_repeated",`
17
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(item, count)
18
- local t = {}
19
- for i = 1, count do
20
- table.insert(t, item)
21
- end
22
- return t
23
- end
24
- `),d=b.valueToCode(a,"ITEM",Order$$module$build$src$generators$lua$lua_generator.NONE)||"nil";a=b.valueToCode(a,"NUM",Order$$module$build$src$generators$lua$lua_generator.NONE)||"0";return[c+"("+d+", "+a+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},lists_length$$module$build$src$generators$lua$lists=function(a,b){return["#"+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua$lua_generator.UNARY)||"{}"),Order$$module$build$src$generators$lua$lua_generator.UNARY]},lists_isEmpty$$module$build$src$generators$lua$lists=
25
- function(a,b){return["#"+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua$lua_generator.UNARY)||"{}")+" == 0",Order$$module$build$src$generators$lua$lua_generator.RELATIONAL]},lists_indexOf$$module$build$src$generators$lua$lists=function(a,b){var c=b.valueToCode(a,"FIND",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''",d=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua$lua_generator.NONE)||"{}";return[(a.getFieldValue("END")==="FIRST"?b.provideFunction_("first_index",
26
- `
27
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
28
- for k, v in ipairs(t) do
29
- if v == elem then
30
- return k
31
- end
32
- end
33
- return 0
34
- end
35
- `):b.provideFunction_("last_index",`
36
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
37
- for i = #t, 1, -1 do
38
- if t[i] == elem then
39
- return i
40
- end
41
- end
42
- return 0
43
- end
44
- `))+"("+d+", "+c+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},lists_getIndex$$module$build$src$generators$lua$lists=function(a,b){var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua$lua_generator.HIGH)||"({})";if(d!=="LAST"&&d!=="FROM_END"&&d!=="RANDOM"||e.match(/^\w+$/)){b=b.valueToCode(a,"AT",c==="GET"&&d==="FROM_END"?Order$$module$build$src$generators$lua$lua_generator.ADDITIVE:Order$$module$build$src$generators$lua$lua_generator.NONE)||
45
- "1";b=getListIndex$$module$build$src$generators$lua$lists(e,d,b);if(c==="GET")return[e+"["+b+"]",Order$$module$build$src$generators$lua$lua_generator.HIGH];d="table.remove("+e+", "+b+")";return c==="GET_REMOVE"?[d,Order$$module$build$src$generators$lua$lua_generator.HIGH]:d+"\n"}if(c==="REMOVE")return c=b.valueToCode(a,"AT",d==="FROM_END"?Order$$module$build$src$generators$lua$lua_generator.ADDITIVE:Order$$module$build$src$generators$lua$lua_generator.NONE)||"1",b=b.nameDB_.getDistinctName("tmp_list",
46
- $.NameType$$module$build$src$core$names.VARIABLE),c=getListIndex$$module$build$src$generators$lua$lists(b,d,c),b+" = "+e+"\ntable.remove("+b+", "+c+")\n";a=b.valueToCode(a,"AT",Order$$module$build$src$generators$lua$lua_generator.NONE)||"1";return[(c==="GET"?b.provideFunction_("list_get_"+d.toLowerCase(),["function "+b.FUNCTION_NAME_PLACEHOLDER_+"(t"+(d==="FROM_END"||d==="FROM_START"?", at)":")")," return t["+getListIndex$$module$build$src$generators$lua$lists("t",d,"at")+"]","end"]):b.provideFunction_("list_remove_"+
47
- d.toLowerCase(),["function "+b.FUNCTION_NAME_PLACEHOLDER_+"(t"+(d==="FROM_END"||d==="FROM_START"?", at)":")")," return table.remove(t, "+getListIndex$$module$build$src$generators$lua$lists("t",d,"at")+")","end"]))+"("+e+(d==="FROM_END"||d==="FROM_START"?", "+a:"")+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},lists_setIndex$$module$build$src$generators$lua$lists=function(a,b){var c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua$lua_generator.HIGH)||"{}",d=a.getFieldValue("MODE")||
48
- "SET",e=a.getFieldValue("WHERE")||"FROM_START",f=b.valueToCode(a,"AT",Order$$module$build$src$generators$lua$lua_generator.ADDITIVE)||"1";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$lua$lua_generator.NONE)||"Nil";var g="";e!=="LAST"&&e!=="FROM_END"&&e!=="RANDOM"||c.match(/^\w+$/)||(b=b.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE),g=b+" = "+c+"\n",c=b);g=d==="SET"?g+(c+"["+getListIndex$$module$build$src$generators$lua$lists(c,e,f)+"] = "+a):g+("table.insert("+
49
- c+", "+(getListIndex$$module$build$src$generators$lua$lists(c,e,f)+(e==="LAST"?" + 1":""))+", "+a+")");return g+"\n"},lists_getSublist$$module$build$src$generators$lua$lists=function(a,b){var c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua$lua_generator.NONE)||"{}",d=a.getFieldValue("WHERE1"),e=a.getFieldValue("WHERE2"),f=b.valueToCode(a,"AT1",Order$$module$build$src$generators$lua$lua_generator.NONE)||"1";a=b.valueToCode(a,"AT2",Order$$module$build$src$generators$lua$lua_generator.NONE)||
50
- "1";var g=d==="FROM_END"||d==="FROM_START"?", at1":"",h=e==="FROM_END"||e==="FROM_START"?", at2":"";return[b.provideFunction_("list_sublist_"+d.toLowerCase()+"_"+e.toLowerCase(),`
51
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(source${g}${h})
52
- local t = {}
53
- local start = ${getListIndex$$module$build$src$generators$lua$lists("source",d,"at1")}
54
- local finish = ${getListIndex$$module$build$src$generators$lua$lists("source",e,"at2")}
55
- for i = start, finish do
56
- table.insert(t, source[i])
57
- end
58
- return t
59
- end
60
- `)+"("+c+(d==="FROM_END"||d==="FROM_START"?", "+f:"")+(e==="FROM_END"||e==="FROM_START"?", "+a:"")+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},lists_sort$$module$build$src$generators$lua$lists=function(a,b){var c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua$lua_generator.NONE)||"{}",d=a.getFieldValue("DIRECTION")==="1"?1:-1;a=a.getFieldValue("TYPE");return[b.provideFunction_("list_sort",`
61
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(list, typev, direction)
62
- local t = {}
63
- for n,v in pairs(list) do table.insert(t, v) end
64
- local compareFuncs = {
65
- NUMERIC = function(a, b)
66
- return (tonumber(tostring(a)) or 0)
67
- < (tonumber(tostring(b)) or 0) end,
68
- TEXT = function(a, b)
69
- return tostring(a) < tostring(b) end,
70
- IGNORE_CASE = function(a, b)
71
- return string.lower(tostring(a)) < string.lower(tostring(b)) end
72
- }
73
- local compareTemp = compareFuncs[typev]
74
- local compare = compareTemp
75
- if direction == -1
76
- then compare = function(a, b) return compareTemp(b, a) end
77
- end
78
- table.sort(t, compare)
79
- return t
80
- end
81
- `)+"("+c+',"'+a+'", '+d+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},lists_split$$module$build$src$generators$lua$lists=function(a,b){var c=b.valueToCode(a,"INPUT",Order$$module$build$src$generators$lua$lua_generator.NONE),d=b.valueToCode(a,"DELIM",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''";a=a.getFieldValue("MODE");if(a==="SPLIT")c||(c="''"),b=b.provideFunction_("list_string_split",`
82
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(input, delim)
83
- local t = {}
84
- local pos = 1
85
- while true do
86
- next_delim = string.find(input, delim, pos)
87
- if next_delim == nil then
88
- table.insert(t, string.sub(input, pos))
89
- break
90
- else
91
- table.insert(t, string.sub(input, pos, next_delim-1))
92
- pos = next_delim + #delim
93
- end
94
- end
95
- return t
96
- end
97
- `);else if(a==="JOIN")c||(c="{}"),b="table.concat";else throw Error("Unknown mode: "+a);return[b+"("+c+", "+d+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},lists_reverse$$module$build$src$generators$lua$lists=function(a,b){a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua$lua_generator.NONE)||"{}";return[b.provideFunction_("list_reverse",`
98
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(input)
99
- local reversed = {}
100
- for i = #input, 1, -1 do
101
- table.insert(reversed, input[i])
102
- end
103
- return reversed
15
+ var gs=function(a,b,c){return b==="FIRST"?"1":b==="FROM_END"?"#"+a+" + 1 - "+c:b==="LAST"?"#"+a:b==="RANDOM"?"math.random(#"+a+")":c},hs=function(a,b){var c=0,d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));do{let e=b.valueToCode(a,"IF"+c,Y.NONE)||"false",f=b.statementToCode(a,"DO"+c);b.STATEMENT_SUFFIX&&(f=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+f);d+=(c>0?"else":"")+"if "+e+" then\n"+f;c++}while(a.getInput("IF"+c));if(a.getInput("ELSE")||b.STATEMENT_SUFFIX)c=a.getInput("ELSE")?
16
+ b.statementToCode(a,"ELSE"):"",b.STATEMENT_SUFFIX&&(c=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+c),d+="else\n"+c;return d+"end\n"},is=function(a,b){return a.includes("goto continue\n")?a+b+"::continue::\n":a},js=function(a,b){var c=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):b.valueToCode(a,"TIMES",Y.NONE)||"0";c=$.df(c)?parseInt(c,10):"math.floor("+c+")";var d=b.statementToCode(a,"DO");d=b.addLoopTrap(d,a);d=is(d,b.INDENT);return"for "+b.nameDB_.getDistinctName("count",
17
+ $.P.VARIABLE)+" = 1, "+c+" do\n"+d+"end\n"},ks=function(a,b){var c=a.getFieldValue("OP");if(c==="NEG")return a=b.valueToCode(a,"NUM",Y.UNARY)||"0",["-"+a,Y.UNARY];if(c==="POW10")return a=b.valueToCode(a,"NUM",Y.EXPONENTIATION)||"0",["10 ^ "+a,Y.EXPONENTIATION];a=c==="ROUND"?b.valueToCode(a,"NUM",Y.ADDITIVE)||"0":b.valueToCode(a,"NUM",Y.NONE)||"0";switch(c){case "ABS":c="math.abs("+a+")";break;case "ROOT":c="math.sqrt("+a+")";break;case "LN":c="math.log("+a+")";break;case "LOG10":c="math.log("+a+", 10)";
18
+ break;case "EXP":c="math.exp("+a+")";break;case "ROUND":c="math.floor("+a+" + .5)";break;case "ROUNDUP":c="math.ceil("+a+")";break;case "ROUNDDOWN":c="math.floor("+a+")";break;case "SIN":c="math.sin(math.rad("+a+"))";break;case "COS":c="math.cos(math.rad("+a+"))";break;case "TAN":c="math.tan(math.rad("+a+"))";break;case "ASIN":c="math.deg(math.asin("+a+"))";break;case "ACOS":c="math.deg(math.acos("+a+"))";break;case "ATAN":c="math.deg(math.atan("+a+"))";break;default:throw Error("Unknown math operator: "+
19
+ c);}return[c,Y.HIGH]},ls=function(a,b){var c=b.getProcedureName(a.getFieldValue("NAME")),d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(d+=b.injectId(b.STATEMENT_SUFFIX,a));d&&(d=b.prefixLines(d,b.INDENT));var e="";b.INFINITE_LOOP_TRAP&&(e=b.prefixLines(b.injectId(b.INFINITE_LOOP_TRAP,a),b.INDENT));var f="";a.getInput("STACK")&&(f=b.statementToCode(a,"STACK"));var g="";a.getInput("RETURN")&&(g=b.valueToCode(a,"RETURN",Y.NONE)||"");var k="";f&&g&&(k=d);g?g=b.INDENT+
20
+ "return "+g+"\n":f||(f="");var m=[],z=a.getVarModels();for(let E=0;E<z.length;E++)m[E]=b.getVariableName(z[E].getId());d="function "+c+"("+m.join(", ")+")\n"+d+e+f+k+g+"end\n";d=b.scrub_(a,d);b.definitions_["%"+c]=d;return null},ms=function(a,b){var c=a.getField("TEXT")?b.quote_(a.getFieldValue("TEXT")):b.valueToCode(a,"TEXT",Y.NONE)||"''";b=b.provideFunction_("text_prompt",`
21
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(msg)
22
+ io.write(msg)
23
+ io.flush()
24
+ return io.read()
104
25
  end
105
- `)+"("+a+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},controls_if$$module$build$src$generators$lua$logic=function(a,b){var c=0,d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));do{let e=b.valueToCode(a,"IF"+c,Order$$module$build$src$generators$lua$lua_generator.NONE)||"false",f=b.statementToCode(a,"DO"+c);b.STATEMENT_SUFFIX&&(f=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+f);d+=(c>0?"else":"")+"if "+e+" then\n"+f;c++}while(a.getInput("IF"+c));if(a.getInput("ELSE")||
106
- b.STATEMENT_SUFFIX)c=a.getInput("ELSE")?b.statementToCode(a,"ELSE"):"",b.STATEMENT_SUFFIX&&(c=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+c),d+="else\n"+c;return d+"end\n"},logic_compare$$module$build$src$generators$lua$logic=function(a,b){var c={EQ:"==",NEQ:"~=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],d=b.valueToCode(a,"A",Order$$module$build$src$generators$lua$lua_generator.RELATIONAL)||"0";a=b.valueToCode(a,"B",Order$$module$build$src$generators$lua$lua_generator.RELATIONAL)||
107
- "0";return[d+" "+c+" "+a,Order$$module$build$src$generators$lua$lua_generator.RELATIONAL]},logic_operation$$module$build$src$generators$lua$logic=function(a,b){var c=a.getFieldValue("OP")==="AND"?"and":"or",d=c==="and"?Order$$module$build$src$generators$lua$lua_generator.AND:Order$$module$build$src$generators$lua$lua_generator.OR,e=b.valueToCode(a,"A",d);a=b.valueToCode(a,"B",d);e||a?(b=c==="and"?"true":"false",e||(e=b),a||(a=b)):a=e="false";return[e+" "+c+" "+a,d]},logic_negate$$module$build$src$generators$lua$logic=
108
- function(a,b){return["not "+(b.valueToCode(a,"BOOL",Order$$module$build$src$generators$lua$lua_generator.UNARY)||"true"),Order$$module$build$src$generators$lua$lua_generator.UNARY]},logic_boolean$$module$build$src$generators$lua$logic=function(a,b){return[a.getFieldValue("BOOL")==="TRUE"?"true":"false",Order$$module$build$src$generators$lua$lua_generator.ATOMIC]},logic_null$$module$build$src$generators$lua$logic=function(a,b){return["nil",Order$$module$build$src$generators$lua$lua_generator.ATOMIC]},
109
- logic_ternary$$module$build$src$generators$lua$logic=function(a,b){var c=b.valueToCode(a,"IF",Order$$module$build$src$generators$lua$lua_generator.AND)||"false",d=b.valueToCode(a,"THEN",Order$$module$build$src$generators$lua$lua_generator.AND)||"nil";a=b.valueToCode(a,"ELSE",Order$$module$build$src$generators$lua$lua_generator.OR)||"nil";return[c+" and "+d+" or "+a,Order$$module$build$src$generators$lua$lua_generator.OR]},addContinueLabel$$module$build$src$generators$lua$loops=function(a,b){return a.includes(CONTINUE_STATEMENT$$module$build$src$generators$lua$loops)?
110
- a+b+"::continue::\n":a},controls_repeat_ext$$module$build$src$generators$lua$loops=function(a,b){var c=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):b.valueToCode(a,"TIMES",Order$$module$build$src$generators$lua$lua_generator.NONE)||"0";c=$.isNumber$$module$build$src$core$utils$string(c)?parseInt(c,10):"math.floor("+c+")";var d=b.statementToCode(a,"DO");d=b.addLoopTrap(d,a);d=addContinueLabel$$module$build$src$generators$lua$loops(d,b.INDENT);return"for "+b.nameDB_.getDistinctName("count",
111
- $.NameType$$module$build$src$core$names.VARIABLE)+" = 1, "+c+" do\n"+d+"end\n"},controls_whileUntil$$module$build$src$generators$lua$loops=function(a,b){var c=a.getFieldValue("MODE")==="UNTIL",d=b.valueToCode(a,"BOOL",c?Order$$module$build$src$generators$lua$lua_generator.UNARY:Order$$module$build$src$generators$lua$lua_generator.NONE)||"false",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a);e=addContinueLabel$$module$build$src$generators$lua$loops(e,b.INDENT);c&&(d="not "+d);return"while "+d+" do\n"+
112
- e+"end\n"},controls_for$$module$build$src$generators$lua$loops=function(a,b){var c=b.getVariableName(a.getFieldValue("VAR")),d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$lua$lua_generator.NONE)||"0",e=b.valueToCode(a,"TO",Order$$module$build$src$generators$lua$lua_generator.NONE)||"0",f=b.valueToCode(a,"BY",Order$$module$build$src$generators$lua$lua_generator.NONE)||"1",g=b.statementToCode(a,"DO");g=b.addLoopTrap(g,a);g=addContinueLabel$$module$build$src$generators$lua$loops(g,b.INDENT);
113
- a="";if($.isNumber$$module$build$src$core$utils$string(d)&&$.isNumber$$module$build$src$core$utils$string(e)&&$.isNumber$$module$build$src$core$utils$string(f))var h=(Number(d)<=Number(e)?"":"-")+Math.abs(Number(f));else a="",h=b.nameDB_.getDistinctName(c+"_inc",$.NameType$$module$build$src$core$names.VARIABLE),a+=h+" = ",a=$.isNumber$$module$build$src$core$utils$string(f)?a+(Math.abs(f)+"\n"):a+("math.abs("+f+")\n"),a=a+("if ("+d+") > ("+e+") then\n")+(b.INDENT+h+" = -"+h+"\n"),a+="end\n";return a+
114
- ("for "+c+" = "+d+", "+e+", "+h)+(" do\n"+g+"end\n")},controls_forEach$$module$build$src$generators$lua$loops=function(a,b){var c=b.getVariableName(a.getFieldValue("VAR")),d=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua$lua_generator.NONE)||"{}",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a);e=addContinueLabel$$module$build$src$generators$lua$loops(e,b.INDENT);return"for _, "+c+" in ipairs("+d+") do \n"+e+"end\n"},controls_flow_statements$$module$build$src$generators$lua$loops=function(a,
115
- b){var c="";b.STATEMENT_PREFIX&&(c+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(c+=b.injectId(b.STATEMENT_SUFFIX,a));if(b.STATEMENT_PREFIX){let d=a.getSurroundLoop();d&&!d.suppressPrefixSuffix&&(c+=b.injectId(b.STATEMENT_PREFIX,d))}switch(a.getFieldValue("FLOW")){case "BREAK":return c+"break\n";case "CONTINUE":return c+CONTINUE_STATEMENT$$module$build$src$generators$lua$loops}throw Error("Unknown flow statement.");},math_number$$module$build$src$generators$lua$math=function(a,b){a=Number(a.getFieldValue("NUM"));
116
- return[String(a),a<0?Order$$module$build$src$generators$lua$lua_generator.UNARY:Order$$module$build$src$generators$lua$lua_generator.ATOMIC]},math_arithmetic$$module$build$src$generators$lua$math=function(a,b){var c={ADD:[" + ",Order$$module$build$src$generators$lua$lua_generator.ADDITIVE],MINUS:[" - ",Order$$module$build$src$generators$lua$lua_generator.ADDITIVE],MULTIPLY:[" * ",Order$$module$build$src$generators$lua$lua_generator.MULTIPLICATIVE],DIVIDE:[" / ",Order$$module$build$src$generators$lua$lua_generator.MULTIPLICATIVE],
117
- POWER:[" ^ ",Order$$module$build$src$generators$lua$lua_generator.EXPONENTIATION]}[a.getFieldValue("OP")],d=c[0];c=c[1];var e=b.valueToCode(a,"A",c)||"0";a=b.valueToCode(a,"B",c)||"0";return[e+d+a,c]},math_single$$module$build$src$generators$lua$math=function(a,b){var c=a.getFieldValue("OP");if(c==="NEG")return a=b.valueToCode(a,"NUM",Order$$module$build$src$generators$lua$lua_generator.UNARY)||"0",["-"+a,Order$$module$build$src$generators$lua$lua_generator.UNARY];if(c==="POW10")return a=b.valueToCode(a,
118
- "NUM",Order$$module$build$src$generators$lua$lua_generator.EXPONENTIATION)||"0",["10 ^ "+a,Order$$module$build$src$generators$lua$lua_generator.EXPONENTIATION];a=c==="ROUND"?b.valueToCode(a,"NUM",Order$$module$build$src$generators$lua$lua_generator.ADDITIVE)||"0":b.valueToCode(a,"NUM",Order$$module$build$src$generators$lua$lua_generator.NONE)||"0";switch(c){case "ABS":c="math.abs("+a+")";break;case "ROOT":c="math.sqrt("+a+")";break;case "LN":c="math.log("+a+")";break;case "LOG10":c="math.log("+a+
119
- ", 10)";break;case "EXP":c="math.exp("+a+")";break;case "ROUND":c="math.floor("+a+" + .5)";break;case "ROUNDUP":c="math.ceil("+a+")";break;case "ROUNDDOWN":c="math.floor("+a+")";break;case "SIN":c="math.sin(math.rad("+a+"))";break;case "COS":c="math.cos(math.rad("+a+"))";break;case "TAN":c="math.tan(math.rad("+a+"))";break;case "ASIN":c="math.deg(math.asin("+a+"))";break;case "ACOS":c="math.deg(math.acos("+a+"))";break;case "ATAN":c="math.deg(math.atan("+a+"))";break;default:throw Error("Unknown math operator: "+
120
- c);}return[c,Order$$module$build$src$generators$lua$lua_generator.HIGH]},math_constant$$module$build$src$generators$lua$math=function(a,b){return{PI:["math.pi",Order$$module$build$src$generators$lua$lua_generator.HIGH],E:["math.exp(1)",Order$$module$build$src$generators$lua$lua_generator.HIGH],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",Order$$module$build$src$generators$lua$lua_generator.MULTIPLICATIVE],SQRT2:["math.sqrt(2)",Order$$module$build$src$generators$lua$lua_generator.HIGH],SQRT1_2:["math.sqrt(1 / 2)",
121
- Order$$module$build$src$generators$lua$lua_generator.HIGH],INFINITY:["math.huge",Order$$module$build$src$generators$lua$lua_generator.HIGH]}[a.getFieldValue("CONSTANT")]},math_number_property$$module$build$src$generators$lua$math=function(a,b){var c={EVEN:[" % 2 == 0",Order$$module$build$src$generators$lua$lua_generator.MULTIPLICATIVE,Order$$module$build$src$generators$lua$lua_generator.RELATIONAL],ODD:[" % 2 == 1",Order$$module$build$src$generators$lua$lua_generator.MULTIPLICATIVE,Order$$module$build$src$generators$lua$lua_generator.RELATIONAL],
122
- WHOLE:[" % 1 == 0",Order$$module$build$src$generators$lua$lua_generator.MULTIPLICATIVE,Order$$module$build$src$generators$lua$lua_generator.RELATIONAL],POSITIVE:[" > 0",Order$$module$build$src$generators$lua$lua_generator.RELATIONAL,Order$$module$build$src$generators$lua$lua_generator.RELATIONAL],NEGATIVE:[" < 0",Order$$module$build$src$generators$lua$lua_generator.RELATIONAL,Order$$module$build$src$generators$lua$lua_generator.RELATIONAL],DIVISIBLE_BY:[null,Order$$module$build$src$generators$lua$lua_generator.MULTIPLICATIVE,
123
- Order$$module$build$src$generators$lua$lua_generator.RELATIONAL],PRIME:[null,Order$$module$build$src$generators$lua$lua_generator.NONE,Order$$module$build$src$generators$lua$lua_generator.HIGH]},d=a.getFieldValue("PROPERTY"),[e,f,g]=c[d];c=b.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";if(d==="PRIME")a=b.provideFunction_("math_isPrime",`
26
+ `)+"("+c+")";a.getFieldValue("TYPE")==="NUMBER"&&(b="tonumber("+b+", 10)");return[b,Y.HIGH]},ns=function(a,b){return[b.getVariableName(a.getFieldValue("VAR")),Y.ATOMIC]},ps=function(a,b){var c=b.valueToCode(a,"VALUE",Y.NONE)||"0";return b.getVariableName(a.getFieldValue("VAR"))+" = "+c+"\n"},Y,qs=Y||(Y={});qs[qs.ATOMIC=0]="ATOMIC";qs[qs.HIGH=1]="HIGH";qs[qs.EXPONENTIATION=2]="EXPONENTIATION";qs[qs.UNARY=3]="UNARY";qs[qs.MULTIPLICATIVE=4]="MULTIPLICATIVE";qs[qs.ADDITIVE=5]="ADDITIVE";
27
+ qs[qs.CONCATENATION=6]="CONCATENATION";qs[qs.RELATIONAL=7]="RELATIONAL";qs[qs.AND=8]="AND";qs[qs.OR=9]="OR";qs[qs.NONE=99]="NONE";
28
+ var rs=class extends $.Ip{constructor(a="Lua"){super(a);this.isInitialized=!1;for(let b in Y)a=Y[b],typeof a!=="string"&&(this["ORDER_"+b]=a);this.addReservedWords("_,__inext,assert,bit,colors,colours,coroutine,disk,dofile,error,fs,fetfenv,getmetatable,gps,help,io,ipairs,keys,loadfile,loadstring,math,native,next,os,paintutils,pairs,parallel,pcall,peripheral,print,printError,rawequal,rawget,rawset,read,rednet,redstone,rs,select,setfenv,setmetatable,sleep,string,table,term,textutils,tonumber,tostring,turtle,type,unpack,vector,write,xpcall,_VERSION,__indext,HTTP,and,break,do,else,elseif,end,false,for,function,if,in,local,nil,not,or,repeat,return,then,true,until,while,add,sub,mul,div,mod,pow,unm,concat,len,eq,lt,le,index,newindex,call,assert,collectgarbage,dofile,error,_G,getmetatable,inpairs,load,loadfile,next,pairs,pcall,print,rawequal,rawget,rawlen,rawset,select,setmetatable,tonumber,tostring,type,_VERSION,xpcall,require,package,string,table,math,bit32,io,file,os,debug")}init(a){super.init(a);this.nameDB_?
29
+ this.nameDB_.reset():this.nameDB_=new $.aj(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);this.isInitialized=!0}finish(a){var b=Object.values(this.definitions_);a=super.finish(a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a}scrubNakedValue(a){return"local _ = "+a+"\n"}quote_(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"}multiline_quote_(a){return a.split(/\n/g).map(this.quote_).join(" .. '\\n' ..\n")}scrub_(a,
30
+ b,c=!1){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.cf(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e,"-- ")+"\n");for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.he.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"-- "))}a=a.nextConnection&&a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c}};var ss={};ss.controls_if=hs;ss.controls_ifelse=hs;ss.logic_boolean=function(a){return[a.getFieldValue("BOOL")==="TRUE"?"true":"false",Y.ATOMIC]};ss.logic_compare=function(a,b){var c={EQ:"==",NEQ:"~=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],d=b.valueToCode(a,"A",Y.RELATIONAL)||"0";a=b.valueToCode(a,"B",Y.RELATIONAL)||"0";return[d+" "+c+" "+a,Y.RELATIONAL]};ss.logic_negate=function(a,b){return["not "+(b.valueToCode(a,"BOOL",Y.UNARY)||"true"),Y.UNARY]};
31
+ ss.logic_null=function(){return["nil",Y.ATOMIC]};ss.logic_operation=function(a,b){var c=a.getFieldValue("OP")==="AND"?"and":"or",d=c==="and"?Y.AND:Y.OR,e=b.valueToCode(a,"A",d);a=b.valueToCode(a,"B",d);e||a?(b=c==="and"?"true":"false",e||(e=b),a||(a=b)):a=e="false";return[e+" "+c+" "+a,d]};ss.logic_ternary=function(a,b){var c=b.valueToCode(a,"IF",Y.AND)||"false",d=b.valueToCode(a,"THEN",Y.AND)||"nil";a=b.valueToCode(a,"ELSE",Y.OR)||"nil";return[c+" and "+d+" or "+a,Y.OR]};var ts={controls_flow_statements:function(a,b){var c="";b.STATEMENT_PREFIX&&(c+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(c+=b.injectId(b.STATEMENT_SUFFIX,a));if(b.STATEMENT_PREFIX){let d=a.getSurroundLoop();d&&!d.suppressPrefixSuffix&&(c+=b.injectId(b.STATEMENT_PREFIX,d))}switch(a.getFieldValue("FLOW")){case "BREAK":return c+"break\n";case "CONTINUE":return c+"goto continue\n"}throw Error("Unknown flow statement.");},controls_for:function(a,b){var c=b.getVariableName(a.getFieldValue("VAR")),
32
+ d=b.valueToCode(a,"FROM",Y.NONE)||"0",e=b.valueToCode(a,"TO",Y.NONE)||"0",f=b.valueToCode(a,"BY",Y.NONE)||"1",g=b.statementToCode(a,"DO");g=b.addLoopTrap(g,a);g=is(g,b.INDENT);a="";if($.df(d)&&$.df(e)&&$.df(f))var k=(Number(d)<=Number(e)?"":"-")+Math.abs(Number(f));else a="",k=b.nameDB_.getDistinctName(c+"_inc",$.P.VARIABLE),a+=k+" = ",a=$.df(f)?a+(Math.abs(f)+"\n"):a+("math.abs("+f+")\n"),a=a+("if ("+d+") > ("+e+") then\n")+(b.INDENT+k+" = -"+k+"\n"),a+="end\n";return a+("for "+c+" = "+d+", "+e+
33
+ ", "+k)+(" do\n"+g+"end\n")},controls_forEach:function(a,b){var c=b.getVariableName(a.getFieldValue("VAR")),d=b.valueToCode(a,"LIST",Y.NONE)||"{}",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a);e=is(e,b.INDENT);return"for _, "+c+" in ipairs("+d+") do \n"+e+"end\n"}};ts.controls_repeat=js;ts.controls_repeat_ext=js;
34
+ ts.controls_whileUntil=function(a,b){var c=a.getFieldValue("MODE")==="UNTIL",d=b.valueToCode(a,"BOOL",c?Y.UNARY:Y.NONE)||"false",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a);e=is(e,b.INDENT);c&&(d="not "+d);return"while "+d+" do\n"+e+"end\n"};var us={math_arithmetic:function(a,b){var c={ADD:[" + ",Y.ADDITIVE],MINUS:[" - ",Y.ADDITIVE],MULTIPLY:[" * ",Y.MULTIPLICATIVE],DIVIDE:[" / ",Y.MULTIPLICATIVE],POWER:[" ^ ",Y.EXPONENTIATION]}[a.getFieldValue("OP")],d=c[0];c=c[1];var e=b.valueToCode(a,"A",c)||"0";a=b.valueToCode(a,"B",c)||"0";return[e+d+a,c]},math_atan2:function(a,b){var c=b.valueToCode(a,"X",Y.NONE)||"0";return["math.deg(math.atan2("+(b.valueToCode(a,"Y",Y.NONE)||"0")+", "+c+"))",Y.HIGH]},math_change:function(a,b){var c=b.valueToCode(a,
35
+ "DELTA",Y.ADDITIVE)||"0";a=b.getVariableName(a.getFieldValue("VAR"));return a+" = "+a+" + "+c+"\n"},math_constant:function(a){return{PI:["math.pi",Y.HIGH],E:["math.exp(1)",Y.HIGH],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",Y.MULTIPLICATIVE],SQRT2:["math.sqrt(2)",Y.HIGH],SQRT1_2:["math.sqrt(1 / 2)",Y.HIGH],INFINITY:["math.huge",Y.HIGH]}[a.getFieldValue("CONSTANT")]},math_constrain:function(a,b){var c=b.valueToCode(a,"VALUE",Y.NONE)||"0",d=b.valueToCode(a,"LOW",Y.NONE)||"-math.huge";a=b.valueToCode(a,"HIGH",
36
+ Y.NONE)||"math.huge";return["math.min(math.max("+c+", "+d+"), "+a+")",Y.HIGH]},math_modulo:function(a,b){var c=b.valueToCode(a,"DIVIDEND",Y.MULTIPLICATIVE)||"0";a=b.valueToCode(a,"DIVISOR",Y.MULTIPLICATIVE)||"0";return[c+" % "+a,Y.MULTIPLICATIVE]},math_number:function(a){a=Number(a.getFieldValue("NUM"));return[String(a),a<0?Y.UNARY:Y.ATOMIC]},math_number_property:function(a,b){var c={EVEN:[" % 2 == 0",Y.MULTIPLICATIVE,Y.RELATIONAL],ODD:[" % 2 == 1",Y.MULTIPLICATIVE,Y.RELATIONAL],WHOLE:[" % 1 == 0",
37
+ Y.MULTIPLICATIVE,Y.RELATIONAL],POSITIVE:[" > 0",Y.RELATIONAL,Y.RELATIONAL],NEGATIVE:[" < 0",Y.RELATIONAL,Y.RELATIONAL],DIVISIBLE_BY:[null,Y.MULTIPLICATIVE,Y.RELATIONAL],PRIME:[null,Y.NONE,Y.HIGH]},d=a.getFieldValue("PROPERTY"),[e,f,g]=c[d];c=b.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";if(d==="PRIME")a=b.provideFunction_("math_isPrime",`
124
38
  function ${b.FUNCTION_NAME_PLACEHOLDER_}(n)
125
39
  -- https://en.wikipedia.org/wiki/Primality_test#Naive_methods
126
40
  if n == 2 or n == 3 then
@@ -139,8 +53,7 @@ function ${b.FUNCTION_NAME_PLACEHOLDER_}(n)
139
53
  end
140
54
  return true
141
55
  end
142
- `)+"("+c+")";else if(d==="DIVISIBLE_BY"){a=b.valueToCode(a,"DIVISOR",Order$$module$build$src$generators$lua$lua_generator.MULTIPLICATIVE)||"0";if(a==="0")return["nil",Order$$module$build$src$generators$lua$lua_generator.ATOMIC];a=c+" % "+a+" == 0"}else a=c+e;return[a,g]},math_change$$module$build$src$generators$lua$math=function(a,b){var c=b.valueToCode(a,"DELTA",Order$$module$build$src$generators$lua$lua_generator.ADDITIVE)||"0";a=b.getVariableName(a.getFieldValue("VAR"));return a+" = "+a+" + "+
143
- c+"\n"},math_on_list$$module$build$src$generators$lua$math=function(a,b){function c(){return b.provideFunction_("math_sum",`
56
+ `)+"("+c+")";else if(d==="DIVISIBLE_BY"){a=b.valueToCode(a,"DIVISOR",Y.MULTIPLICATIVE)||"0";if(a==="0")return["nil",Y.ATOMIC];a=c+" % "+a+" == 0"}else a=c+e;return[a,g]},math_on_list:function(a,b){function c(){return b.provideFunction_("math_sum",`
144
57
  function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
145
58
  local result = 0
146
59
  for _, v in ipairs(t) do
@@ -148,7 +61,7 @@ function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
148
61
  end
149
62
  return result
150
63
  end
151
- `)}var d=a.getFieldValue("OP");a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua$lua_generator.NONE)||"{}";switch(d){case "SUM":d=c();break;case "MIN":d=b.provideFunction_("math_min",`
64
+ `)}var d=a.getFieldValue("OP");a=b.valueToCode(a,"LIST",Y.NONE)||"{}";switch(d){case "SUM":d=c();break;case "MIN":d=b.provideFunction_("math_min",`
152
65
  function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
153
66
  if #t == 0 then
154
67
  return 0
@@ -250,44 +163,8 @@ function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
250
163
  end
251
164
  return t[math.random(#t)]
252
165
  end
253
- `);break;default:throw Error("Unknown operator: "+d);}return[d+"("+a+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},math_modulo$$module$build$src$generators$lua$math=function(a,b){var c=b.valueToCode(a,"DIVIDEND",Order$$module$build$src$generators$lua$lua_generator.MULTIPLICATIVE)||"0";a=b.valueToCode(a,"DIVISOR",Order$$module$build$src$generators$lua$lua_generator.MULTIPLICATIVE)||"0";return[c+" % "+a,Order$$module$build$src$generators$lua$lua_generator.MULTIPLICATIVE]},math_constrain$$module$build$src$generators$lua$math=
254
- function(a,b){var c=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua$lua_generator.NONE)||"0",d=b.valueToCode(a,"LOW",Order$$module$build$src$generators$lua$lua_generator.NONE)||"-math.huge";a=b.valueToCode(a,"HIGH",Order$$module$build$src$generators$lua$lua_generator.NONE)||"math.huge";return["math.min(math.max("+c+", "+d+"), "+a+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},math_random_int$$module$build$src$generators$lua$math=function(a,b){var c=b.valueToCode(a,
255
- "FROM",Order$$module$build$src$generators$lua$lua_generator.NONE)||"0";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$lua$lua_generator.NONE)||"0";return["math.random("+c+", "+a+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},math_random_float$$module$build$src$generators$lua$math=function(a,b){return["math.random()",Order$$module$build$src$generators$lua$lua_generator.HIGH]},math_atan2$$module$build$src$generators$lua$math=function(a,b){var c=b.valueToCode(a,"X",Order$$module$build$src$generators$lua$lua_generator.NONE)||
256
- "0";return["math.deg(math.atan2("+(b.valueToCode(a,"Y",Order$$module$build$src$generators$lua$lua_generator.NONE)||"0")+", "+c+"))",Order$$module$build$src$generators$lua$lua_generator.HIGH]},procedures_defreturn$$module$build$src$generators$lua$procedures=function(a,b){var c=b.getProcedureName(a.getFieldValue("NAME")),d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(d+=b.injectId(b.STATEMENT_SUFFIX,a));d&&(d=b.prefixLines(d,b.INDENT));var e="";b.INFINITE_LOOP_TRAP&&
257
- (e=b.prefixLines(b.injectId(b.INFINITE_LOOP_TRAP,a),b.INDENT));var f="";a.getInput("STACK")&&(f=b.statementToCode(a,"STACK"));var g="";a.getInput("RETURN")&&(g=b.valueToCode(a,"RETURN",Order$$module$build$src$generators$lua$lua_generator.NONE)||"");var h="";f&&g&&(h=d);g?g=b.INDENT+"return "+g+"\n":f||(f="");var k=[],l=a.getVarModels();for(let m=0;m<l.length;m++)k[m]=b.getVariableName(l[m].getId());d="function "+c+"("+k.join(", ")+")\n"+d+e+f+h+g+"end\n";d=b.scrub_(a,d);b.definitions_["%"+c]=d;return null},
258
- procedures_callreturn$$module$build$src$generators$lua$procedures=function(a,b){var c=b.getProcedureName(a.getFieldValue("NAME")),d=[],e=a.getVarModels();for(let f=0;f<e.length;f++)d[f]=b.valueToCode(a,"ARG"+f,Order$$module$build$src$generators$lua$lua_generator.NONE)||"nil";return[c+"("+d.join(", ")+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},procedures_callnoreturn$$module$build$src$generators$lua$procedures=function(a,b){return b.forBlock.procedures_callreturn(a,b)[0]+"\n"},
259
- procedures_ifreturn$$module$build$src$generators$lua$procedures=function(a,b){var c="if "+(b.valueToCode(a,"CONDITION",Order$$module$build$src$generators$lua$lua_generator.NONE)||"false")+" then\n";b.STATEMENT_SUFFIX&&(c+=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT));a.hasReturnValue_?(a=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua$lua_generator.NONE)||"nil",c+=b.INDENT+"return "+a+"\n"):c+=b.INDENT+"return\n";return c+"end\n"},text$$module$build$src$generators$lua$text=
260
- function(a,b){return[b.quote_(a.getFieldValue("TEXT")),Order$$module$build$src$generators$lua$lua_generator.ATOMIC]},text_join$$module$build$src$generators$lua$text=function(a,b){if(a.itemCount_===0)return["''",Order$$module$build$src$generators$lua$lua_generator.ATOMIC];if(a.itemCount_===1)return["tostring("+(b.valueToCode(a,"ADD0",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''")+")",Order$$module$build$src$generators$lua$lua_generator.HIGH];if(a.itemCount_===2){var c=b.valueToCode(a,
261
- "ADD0",Order$$module$build$src$generators$lua$lua_generator.CONCATENATION)||"''";a=b.valueToCode(a,"ADD1",Order$$module$build$src$generators$lua$lua_generator.CONCATENATION)||"''";return[c+" .. "+a,Order$$module$build$src$generators$lua$lua_generator.CONCATENATION]}c=[];for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,Order$$module$build$src$generators$lua$lua_generator.NONE)||"''";return["table.concat({"+c.join(", ")+"})",Order$$module$build$src$generators$lua$lua_generator.HIGH]},text_append$$module$build$src$generators$lua$text=
262
- function(a,b){var c=b.getVariableName(a.getFieldValue("VAR"));a=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua$lua_generator.CONCATENATION)||"''";return c+" = "+c+" .. "+a+"\n"},text_length$$module$build$src$generators$lua$text=function(a,b){return["#"+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua$lua_generator.UNARY)||"''"),Order$$module$build$src$generators$lua$lua_generator.UNARY]},text_isEmpty$$module$build$src$generators$lua$text=function(a,b){return["#"+(b.valueToCode(a,
263
- "VALUE",Order$$module$build$src$generators$lua$lua_generator.UNARY)||"''")+" == 0",Order$$module$build$src$generators$lua$lua_generator.RELATIONAL]},text_indexOf$$module$build$src$generators$lua$text=function(a,b){var c=b.valueToCode(a,"FIND",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''",d=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''";return[(a.getFieldValue("END")==="FIRST"?b.provideFunction_("firstIndexOf",`
264
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
265
- local i = string.find(str, substr, 1, true)
266
- if i == nil then
267
- return 0
268
- end
269
- return i
270
- end
271
- `):b.provideFunction_("lastIndexOf",`
272
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
273
- local i = string.find(string.reverse(str), string.reverse(substr), 1, true)
274
- if i then
275
- return #str + 2 - i - #substr
276
- end
277
- return 0
278
- end
279
- `))+"("+d+", "+c+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},text_charAt$$module$build$src$generators$lua$text=function(a,b){var c=a.getFieldValue("WHERE")||"FROM_START",d=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''";if(c==="RANDOM")b=b.provideFunction_("text_random_letter",`
280
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(str)
281
- local index = math.random(string.len(str))
282
- return string.sub(str, index, index)
283
- end
284
- `)+"("+d+")";else{if(c==="FIRST")c="1";else if(c==="LAST")c="-1";else if(a=b.valueToCode(a,"AT",c==="FROM_END"?Order$$module$build$src$generators$lua$lua_generator.UNARY:Order$$module$build$src$generators$lua$lua_generator.NONE)||"1",c==="FROM_START")c=a;else if(c==="FROM_END")c="-"+a;else throw Error("Unhandled option (text_charAt).");b=c.match(/^-?\w*$/)?"string.sub("+d+", "+c+", "+c+")":b.provideFunction_("text_char_at",`
285
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(str, index)
286
- return string.sub(str, index, index)
287
- end
288
- `)+"("+d+", "+c+")"}return[b,Order$$module$build$src$generators$lua$lua_generator.HIGH]},text_getSubstring$$module$build$src$generators$lua$text=function(a,b){var c=b.valueToCode(a,"STRING",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''",d=a.getFieldValue("WHERE1"),e=b.valueToCode(a,"AT1",d==="FROM_END"?Order$$module$build$src$generators$lua$lua_generator.UNARY:Order$$module$build$src$generators$lua$lua_generator.NONE)||"1";if(d==="FIRST")d=1;else if(d==="FROM_START")d=e;else if(d===
289
- "FROM_END")d="-"+e;else throw Error("Unhandled option (text_getSubstring)");e=a.getFieldValue("WHERE2");a=b.valueToCode(a,"AT2",e==="FROM_END"?Order$$module$build$src$generators$lua$lua_generator.UNARY:Order$$module$build$src$generators$lua$lua_generator.NONE)||"1";if(e==="LAST")a=-1;else if(e!=="FROM_START")if(e==="FROM_END")a="-"+a;else throw Error("Unhandled option (text_getSubstring)");return["string.sub("+c+", "+d+", "+a+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},text_changeCase$$module$build$src$generators$lua$text=
290
- function(a,b){var c=a.getFieldValue("CASE");a=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''";var d;c==="UPPERCASE"?d="string.upper":c==="LOWERCASE"?d="string.lower":c==="TITLECASE"&&(d=b.provideFunction_("text_titlecase",`
166
+ `);break;default:throw Error("Unknown operator: "+d);}return[d+"("+a+")",Y.HIGH]},math_random_float:function(){return["math.random()",Y.HIGH]},math_random_int:function(a,b){var c=b.valueToCode(a,"FROM",Y.NONE)||"0";a=b.valueToCode(a,"TO",Y.NONE)||"0";return["math.random("+c+", "+a+")",Y.HIGH]}};us.math_round=ks;us.math_single=ks;us.math_trig=ks;var vs={procedures_callnoreturn:function(a,b){return b.forBlock.procedures_callreturn(a,b)[0]+"\n"},procedures_callreturn:function(a,b){var c=b.getProcedureName(a.getFieldValue("NAME")),d=[],e=a.getVarModels();for(let f=0;f<e.length;f++)d[f]=b.valueToCode(a,"ARG"+f,Y.NONE)||"nil";return[c+"("+d.join(", ")+")",Y.HIGH]}};vs.procedures_defnoreturn=ls;vs.procedures_defreturn=ls;
167
+ vs.procedures_ifreturn=function(a,b){var c="if "+(b.valueToCode(a,"CONDITION",Y.NONE)||"false")+" then\n";b.STATEMENT_SUFFIX&&(c+=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT));a.hasReturnValue_?(a=b.valueToCode(a,"VALUE",Y.NONE)||"nil",c+=b.INDENT+"return "+a+"\n"):c+=b.INDENT+"return\n";return c+"end\n"};var ws={text:function(a,b){return[b.quote_(a.getFieldValue("TEXT")),Y.ATOMIC]},text_append:function(a,b){var c=b.getVariableName(a.getFieldValue("VAR"));a=b.valueToCode(a,"TEXT",Y.CONCATENATION)||"''";return c+" = "+c+" .. "+a+"\n"},text_changeCase:function(a,b){var c=a.getFieldValue("CASE");a=b.valueToCode(a,"TEXT",Y.NONE)||"''";var d;c==="UPPERCASE"?d="string.upper":c==="LOWERCASE"?d="string.lower":c==="TITLECASE"&&(d=b.provideFunction_("text_titlecase",`
291
168
  function ${b.FUNCTION_NAME_PLACEHOLDER_}(str)
292
169
  local buf = {}
293
170
  local inWord = false
@@ -305,14 +182,16 @@ function ${b.FUNCTION_NAME_PLACEHOLDER_}(str)
305
182
  end
306
183
  return table.concat(buf)
307
184
  end
308
- `));return[d+"("+a+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},text_trim$$module$build$src$generators$lua$text=function(a,b){var c={LEFT:"^%s*(,-)",RIGHT:"(.-)%s*$",BOTH:"^%s*(.-)%s*$"}[a.getFieldValue("MODE")];return["string.gsub("+(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''")+', "'+c+'", "%1")',Order$$module$build$src$generators$lua$lua_generator.HIGH]},text_print$$module$build$src$generators$lua$text=function(a,b){return"print("+(b.valueToCode(a,
309
- "TEXT",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''")+")\n"},text_prompt_ext$$module$build$src$generators$lua$text=function(a,b){var c=a.getField("TEXT")?b.quote_(a.getFieldValue("TEXT")):b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''";b=b.provideFunction_("text_prompt",`
310
- function ${b.FUNCTION_NAME_PLACEHOLDER_}(msg)
311
- io.write(msg)
312
- io.flush()
313
- return io.read()
185
+ `));return[d+"("+a+")",Y.HIGH]},text_charAt:function(a,b){var c=a.getFieldValue("WHERE")||"FROM_START",d=b.valueToCode(a,"VALUE",Y.NONE)||"''";if(c==="RANDOM")b=b.provideFunction_("text_random_letter",`
186
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(str)
187
+ local index = math.random(string.len(str))
188
+ return string.sub(str, index, index)
314
189
  end
315
- `)+"("+c+")";a.getFieldValue("TYPE")==="NUMBER"&&(b="tonumber("+b+", 10)");return[b,Order$$module$build$src$generators$lua$lua_generator.HIGH]},text_count$$module$build$src$generators$lua$text=function(a,b){var c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''";a=b.valueToCode(a,"SUB",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''";return[b.provideFunction_("text_count",`
190
+ `)+"("+d+")";else{if(c==="FIRST")c="1";else if(c==="LAST")c="-1";else if(a=b.valueToCode(a,"AT",c==="FROM_END"?Y.UNARY:Y.NONE)||"1",c==="FROM_START")c=a;else if(c==="FROM_END")c="-"+a;else throw Error("Unhandled option (text_charAt).");b=c.match(/^-?\w*$/)?"string.sub("+d+", "+c+", "+c+")":b.provideFunction_("text_char_at",`
191
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(str, index)
192
+ return string.sub(str, index, index)
193
+ end
194
+ `)+"("+d+", "+c+")"}return[b,Y.HIGH]},text_count:function(a,b){var c=b.valueToCode(a,"TEXT",Y.NONE)||"''";a=b.valueToCode(a,"SUB",Y.NONE)||"''";return[b.provideFunction_("text_count",`
316
195
  function ${b.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle)
317
196
  if #needle == 0 then
318
197
  return #haystack + 1
@@ -329,7 +208,25 @@ function ${b.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle)
329
208
  end
330
209
  return count
331
210
  end
332
- `)+"("+c+", "+a+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},text_replace$$module$build$src$generators$lua$text=function(a,b){var c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''",d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''";return[b.provideFunction_("text_replace",`
211
+ `)+"("+c+", "+a+")",Y.HIGH]},text_getSubstring:function(a,b){var c=b.valueToCode(a,"STRING",Y.NONE)||"''",d=a.getFieldValue("WHERE1"),e=b.valueToCode(a,"AT1",d==="FROM_END"?Y.UNARY:Y.NONE)||"1";if(d==="FIRST")d=1;else if(d==="FROM_START")d=e;else if(d==="FROM_END")d="-"+e;else throw Error("Unhandled option (text_getSubstring)");e=a.getFieldValue("WHERE2");a=b.valueToCode(a,"AT2",e==="FROM_END"?Y.UNARY:Y.NONE)||"1";if(e==="LAST")a=-1;else if(e!=="FROM_START")if(e==="FROM_END")a="-"+a;else throw Error("Unhandled option (text_getSubstring)");
212
+ return["string.sub("+c+", "+d+", "+a+")",Y.HIGH]},text_indexOf:function(a,b){var c=b.valueToCode(a,"FIND",Y.NONE)||"''",d=b.valueToCode(a,"VALUE",Y.NONE)||"''";return[(a.getFieldValue("END")==="FIRST"?b.provideFunction_("firstIndexOf",`
213
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
214
+ local i = string.find(str, substr, 1, true)
215
+ if i == nil then
216
+ return 0
217
+ end
218
+ return i
219
+ end
220
+ `):b.provideFunction_("lastIndexOf",`
221
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
222
+ local i = string.find(string.reverse(str), string.reverse(substr), 1, true)
223
+ if i then
224
+ return #str + 2 - i - #substr
225
+ end
226
+ return 0
227
+ end
228
+ `))+"("+d+", "+c+")",Y.HIGH]},text_isEmpty:function(a,b){return["#"+(b.valueToCode(a,"VALUE",Y.UNARY)||"''")+" == 0",Y.RELATIONAL]},text_join:function(a,b){if(a.itemCount_===0)return["''",Y.ATOMIC];if(a.itemCount_===1)return["tostring("+(b.valueToCode(a,"ADD0",Y.NONE)||"''")+")",Y.HIGH];if(a.itemCount_===2){var c=b.valueToCode(a,"ADD0",Y.CONCATENATION)||"''";a=b.valueToCode(a,"ADD1",Y.CONCATENATION)||"''";return[c+" .. "+a,Y.CONCATENATION]}c=[];for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,
229
+ "ADD"+d,Y.NONE)||"''";return["table.concat({"+c.join(", ")+"})",Y.HIGH]},text_length:function(a,b){return["#"+(b.valueToCode(a,"VALUE",Y.UNARY)||"''"),Y.UNARY]},text_print:function(a,b){return"print("+(b.valueToCode(a,"TEXT",Y.NONE)||"''")+")\n"}};ws.text_prompt=ms;ws.text_prompt_ext=ms;ws.text_replace=function(a,b){var c=b.valueToCode(a,"TEXT",Y.NONE)||"''",d=b.valueToCode(a,"FROM",Y.NONE)||"''";a=b.valueToCode(a,"TO",Y.NONE)||"''";return[b.provideFunction_("text_replace",`
333
230
  function ${b.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement)
334
231
  local buf = {}
335
232
  local i = 1
@@ -346,27 +243,94 @@ function ${b.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement)
346
243
  end
347
244
  return table.concat(buf)
348
245
  end
349
- `)+"("+c+", "+d+", "+a+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},text_reverse$$module$build$src$generators$lua$text=function(a,b){return["string.reverse("+(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua$lua_generator.NONE)||"''")+")",Order$$module$build$src$generators$lua$lua_generator.HIGH]},variables_get$$module$build$src$generators$lua$variables=function(a,b){return[b.getVariableName(a.getFieldValue("VAR")),Order$$module$build$src$generators$lua$lua_generator.ATOMIC]},
350
- variables_set$$module$build$src$generators$lua$variables=function(a,b){var c=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua$lua_generator.NONE)||"0";return b.getVariableName(a.getFieldValue("VAR"))+" = "+c+"\n"},Order$$module$build$src$generators$lua$lua_generator;
351
- (function(a){a[a.ATOMIC=0]="ATOMIC";a[a.HIGH=1]="HIGH";a[a.EXPONENTIATION=2]="EXPONENTIATION";a[a.UNARY=3]="UNARY";a[a.MULTIPLICATIVE=4]="MULTIPLICATIVE";a[a.ADDITIVE=5]="ADDITIVE";a[a.CONCATENATION=6]="CONCATENATION";a[a.RELATIONAL=7]="RELATIONAL";a[a.AND=8]="AND";a[a.OR=9]="OR";a[a.NONE=99]="NONE"})(Order$$module$build$src$generators$lua$lua_generator||(Order$$module$build$src$generators$lua$lua_generator={}));
352
- var LuaGenerator$$module$build$src$generators$lua$lua_generator=class extends $.CodeGenerator$$module$build$src$core$generator{constructor(a="Lua"){super(a);this.isInitialized=!1;for(let b in Order$$module$build$src$generators$lua$lua_generator)a=Order$$module$build$src$generators$lua$lua_generator[b],typeof a!=="string"&&(this["ORDER_"+b]=a);this.addReservedWords("_,__inext,assert,bit,colors,colours,coroutine,disk,dofile,error,fs,fetfenv,getmetatable,gps,help,io,ipairs,keys,loadfile,loadstring,math,native,next,os,paintutils,pairs,parallel,pcall,peripheral,print,printError,rawequal,rawget,rawset,read,rednet,redstone,rs,select,setfenv,setmetatable,sleep,string,table,term,textutils,tonumber,tostring,turtle,type,unpack,vector,write,xpcall,_VERSION,__indext,HTTP,and,break,do,else,elseif,end,false,for,function,if,in,local,nil,not,or,repeat,return,then,true,until,while,add,sub,mul,div,mod,pow,unm,concat,len,eq,lt,le,index,newindex,call,assert,collectgarbage,dofile,error,_G,getmetatable,inpairs,load,loadfile,next,pairs,pcall,print,rawequal,rawget,rawlen,rawset,select,setmetatable,tonumber,tostring,type,_VERSION,xpcall,require,package,string,table,math,bit32,io,file,os,debug")}init(a){super.init(a);
353
- this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.Names$$module$build$src$core$names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);this.isInitialized=!0}finish(a){var b=Object.values(this.definitions_);a=super.finish(a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a}scrubNakedValue(a){return"local _ = "+a+"\n"}quote_(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,
354
- "\\'");return"'"+a+"'"}multiline_quote_(a){return a.split(/\n/g).map(this.quote_).join(" .. '\\n' ..\n")}scrub_(a,b,c=!1){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.wrap$$module$build$src$core$utils$string(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e,"-- ")+"\n");for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.inputTypes$$module$build$src$core$inputs$input_types.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&
355
- (d+=this.prefixLines(e,"-- "))}a=a.nextConnection&&a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c}},module$build$src$generators$lua$lua_generator={};module$build$src$generators$lua$lua_generator.LuaGenerator=LuaGenerator$$module$build$src$generators$lua$lua_generator;module$build$src$generators$lua$lua_generator.Order=Order$$module$build$src$generators$lua$lua_generator;var getListIndex$$module$build$src$generators$lua$lists=function(a,b,c){return b==="FIRST"?"1":b==="FROM_END"?"#"+a+" + 1 - "+c:b==="LAST"?"#"+a:b==="RANDOM"?"math.random(#"+a+")":c},module$build$src$generators$lua$lists={};module$build$src$generators$lua$lists.lists_create_empty=lists_create_empty$$module$build$src$generators$lua$lists;module$build$src$generators$lua$lists.lists_create_with=lists_create_with$$module$build$src$generators$lua$lists;
356
- module$build$src$generators$lua$lists.lists_getIndex=lists_getIndex$$module$build$src$generators$lua$lists;module$build$src$generators$lua$lists.lists_getSublist=lists_getSublist$$module$build$src$generators$lua$lists;module$build$src$generators$lua$lists.lists_indexOf=lists_indexOf$$module$build$src$generators$lua$lists;module$build$src$generators$lua$lists.lists_isEmpty=lists_isEmpty$$module$build$src$generators$lua$lists;module$build$src$generators$lua$lists.lists_length=lists_length$$module$build$src$generators$lua$lists;
357
- module$build$src$generators$lua$lists.lists_repeat=lists_repeat$$module$build$src$generators$lua$lists;module$build$src$generators$lua$lists.lists_reverse=lists_reverse$$module$build$src$generators$lua$lists;module$build$src$generators$lua$lists.lists_setIndex=lists_setIndex$$module$build$src$generators$lua$lists;module$build$src$generators$lua$lists.lists_sort=lists_sort$$module$build$src$generators$lua$lists;module$build$src$generators$lua$lists.lists_split=lists_split$$module$build$src$generators$lua$lists;var controls_ifelse$$module$build$src$generators$lua$logic=controls_if$$module$build$src$generators$lua$logic,module$build$src$generators$lua$logic={};module$build$src$generators$lua$logic.controls_if=controls_if$$module$build$src$generators$lua$logic;module$build$src$generators$lua$logic.controls_ifelse=controls_if$$module$build$src$generators$lua$logic;module$build$src$generators$lua$logic.logic_boolean=logic_boolean$$module$build$src$generators$lua$logic;
358
- module$build$src$generators$lua$logic.logic_compare=logic_compare$$module$build$src$generators$lua$logic;module$build$src$generators$lua$logic.logic_negate=logic_negate$$module$build$src$generators$lua$logic;module$build$src$generators$lua$logic.logic_null=logic_null$$module$build$src$generators$lua$logic;module$build$src$generators$lua$logic.logic_operation=logic_operation$$module$build$src$generators$lua$logic;module$build$src$generators$lua$logic.logic_ternary=logic_ternary$$module$build$src$generators$lua$logic;var CONTINUE_STATEMENT$$module$build$src$generators$lua$loops="goto continue\n",controls_repeat$$module$build$src$generators$lua$loops=controls_repeat_ext$$module$build$src$generators$lua$loops,module$build$src$generators$lua$loops={};module$build$src$generators$lua$loops.controls_flow_statements=controls_flow_statements$$module$build$src$generators$lua$loops;module$build$src$generators$lua$loops.controls_for=controls_for$$module$build$src$generators$lua$loops;
359
- module$build$src$generators$lua$loops.controls_forEach=controls_forEach$$module$build$src$generators$lua$loops;module$build$src$generators$lua$loops.controls_repeat=controls_repeat_ext$$module$build$src$generators$lua$loops;module$build$src$generators$lua$loops.controls_repeat_ext=controls_repeat_ext$$module$build$src$generators$lua$loops;module$build$src$generators$lua$loops.controls_whileUntil=controls_whileUntil$$module$build$src$generators$lua$loops;var math_round$$module$build$src$generators$lua$math=math_single$$module$build$src$generators$lua$math,math_trig$$module$build$src$generators$lua$math=math_single$$module$build$src$generators$lua$math,module$build$src$generators$lua$math={};module$build$src$generators$lua$math.math_arithmetic=math_arithmetic$$module$build$src$generators$lua$math;module$build$src$generators$lua$math.math_atan2=math_atan2$$module$build$src$generators$lua$math;module$build$src$generators$lua$math.math_change=math_change$$module$build$src$generators$lua$math;
360
- module$build$src$generators$lua$math.math_constant=math_constant$$module$build$src$generators$lua$math;module$build$src$generators$lua$math.math_constrain=math_constrain$$module$build$src$generators$lua$math;module$build$src$generators$lua$math.math_modulo=math_modulo$$module$build$src$generators$lua$math;module$build$src$generators$lua$math.math_number=math_number$$module$build$src$generators$lua$math;module$build$src$generators$lua$math.math_number_property=math_number_property$$module$build$src$generators$lua$math;
361
- module$build$src$generators$lua$math.math_on_list=math_on_list$$module$build$src$generators$lua$math;module$build$src$generators$lua$math.math_random_float=math_random_float$$module$build$src$generators$lua$math;module$build$src$generators$lua$math.math_random_int=math_random_int$$module$build$src$generators$lua$math;module$build$src$generators$lua$math.math_round=math_single$$module$build$src$generators$lua$math;module$build$src$generators$lua$math.math_single=math_single$$module$build$src$generators$lua$math;
362
- module$build$src$generators$lua$math.math_trig=math_single$$module$build$src$generators$lua$math;var procedures_defnoreturn$$module$build$src$generators$lua$procedures=procedures_defreturn$$module$build$src$generators$lua$procedures,module$build$src$generators$lua$procedures={};module$build$src$generators$lua$procedures.procedures_callnoreturn=procedures_callnoreturn$$module$build$src$generators$lua$procedures;module$build$src$generators$lua$procedures.procedures_callreturn=procedures_callreturn$$module$build$src$generators$lua$procedures;
363
- module$build$src$generators$lua$procedures.procedures_defnoreturn=procedures_defreturn$$module$build$src$generators$lua$procedures;module$build$src$generators$lua$procedures.procedures_defreturn=procedures_defreturn$$module$build$src$generators$lua$procedures;module$build$src$generators$lua$procedures.procedures_ifreturn=procedures_ifreturn$$module$build$src$generators$lua$procedures;var text_prompt$$module$build$src$generators$lua$text=text_prompt_ext$$module$build$src$generators$lua$text,module$build$src$generators$lua$text={};module$build$src$generators$lua$text.text=text$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_append=text_append$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_changeCase=text_changeCase$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_charAt=text_charAt$$module$build$src$generators$lua$text;
364
- module$build$src$generators$lua$text.text_count=text_count$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_getSubstring=text_getSubstring$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_indexOf=text_indexOf$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_isEmpty=text_isEmpty$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_join=text_join$$module$build$src$generators$lua$text;
365
- module$build$src$generators$lua$text.text_length=text_length$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_print=text_print$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_prompt=text_prompt_ext$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_prompt_ext=text_prompt_ext$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_replace=text_replace$$module$build$src$generators$lua$text;
366
- module$build$src$generators$lua$text.text_reverse=text_reverse$$module$build$src$generators$lua$text;module$build$src$generators$lua$text.text_trim=text_trim$$module$build$src$generators$lua$text;var module$build$src$generators$lua$variables={};module$build$src$generators$lua$variables.variables_get=variables_get$$module$build$src$generators$lua$variables;module$build$src$generators$lua$variables.variables_set=variables_set$$module$build$src$generators$lua$variables;var module$build$src$generators$lua$variables_dynamic={};module$build$src$generators$lua$variables_dynamic.variables_get_dynamic=variables_get$$module$build$src$generators$lua$variables;module$build$src$generators$lua$variables_dynamic.variables_set_dynamic=variables_set$$module$build$src$generators$lua$variables;var luaGenerator$$module$build$src$generators$lua=new LuaGenerator$$module$build$src$generators$lua$lua_generator,generators$$module$build$src$generators$lua=Object.assign({},module$build$src$generators$lua$lists,module$build$src$generators$lua$logic,module$build$src$generators$lua$loops,module$build$src$generators$lua$math,module$build$src$generators$lua$procedures,module$build$src$generators$lua$text,module$build$src$generators$lua$variables,module$build$src$generators$lua$variables_dynamic);
367
- for(let a in generators$$module$build$src$generators$lua)luaGenerator$$module$build$src$generators$lua.forBlock[a]=generators$$module$build$src$generators$lua[a];var module$build$src$generators$lua={};module$build$src$generators$lua.LuaGenerator=LuaGenerator$$module$build$src$generators$lua$lua_generator;module$build$src$generators$lua.Order=Order$$module$build$src$generators$lua$lua_generator;module$build$src$generators$lua.luaGenerator=luaGenerator$$module$build$src$generators$lua;
368
- module$build$src$generators$lua.__namespace__=$;
369
- return module$build$src$generators$lua;
246
+ `)+"("+c+", "+d+", "+a+")",Y.HIGH]};ws.text_reverse=function(a,b){return["string.reverse("+(b.valueToCode(a,"TEXT",Y.NONE)||"''")+")",Y.HIGH]};ws.text_trim=function(a,b){var c={LEFT:"^%s*(,-)",RIGHT:"(.-)%s*$",BOTH:"^%s*(.-)%s*$"}[a.getFieldValue("MODE")];return["string.gsub("+(b.valueToCode(a,"TEXT",Y.NONE)||"''")+', "'+c+'", "%1")',Y.HIGH]};var xs={};xs.variables_get=ns;xs.variables_set=ps;var ys={};ys.variables_get_dynamic=ns;ys.variables_set_dynamic=ps;var zs=new rs,As=Object.assign({},{lists_create_empty:function(){return["{}",Y.HIGH]},lists_create_with:function(a,b){var c=Array(a.itemCount_);for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,Y.NONE)||"nil";return["{"+c.join(", ")+"}",Y.HIGH]},lists_getIndex:function(a,b){var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=b.valueToCode(a,"VALUE",Y.HIGH)||"({})";if(d!=="LAST"&&d!=="FROM_END"&&d!=="RANDOM"||e.match(/^\w+$/)){b=b.valueToCode(a,"AT",c==="GET"&&
247
+ d==="FROM_END"?Y.ADDITIVE:Y.NONE)||"1";b=gs(e,d,b);if(c==="GET")return[e+"["+b+"]",Y.HIGH];d="table.remove("+e+", "+b+")";return c==="GET_REMOVE"?[d,Y.HIGH]:d+"\n"}if(c==="REMOVE")return c=b.valueToCode(a,"AT",d==="FROM_END"?Y.ADDITIVE:Y.NONE)||"1",b=b.nameDB_.getDistinctName("tmp_list",$.P.VARIABLE),c=gs(b,d,c),b+" = "+e+"\ntable.remove("+b+", "+c+")\n";a=b.valueToCode(a,"AT",Y.NONE)||"1";return[(c==="GET"?b.provideFunction_("list_get_"+d.toLowerCase(),["function "+b.FUNCTION_NAME_PLACEHOLDER_+"(t"+
248
+ (d==="FROM_END"||d==="FROM_START"?", at)":")")," return t["+gs("t",d,"at")+"]","end"]):b.provideFunction_("list_remove_"+d.toLowerCase(),["function "+b.FUNCTION_NAME_PLACEHOLDER_+"(t"+(d==="FROM_END"||d==="FROM_START"?", at)":")")," return table.remove(t, "+gs("t",d,"at")+")","end"]))+"("+e+(d==="FROM_END"||d==="FROM_START"?", "+a:"")+")",Y.HIGH]},lists_getSublist:function(a,b){var c=b.valueToCode(a,"LIST",Y.NONE)||"{}",d=a.getFieldValue("WHERE1"),e=a.getFieldValue("WHERE2"),f=b.valueToCode(a,"AT1",
249
+ Y.NONE)||"1";a=b.valueToCode(a,"AT2",Y.NONE)||"1";var g=d==="FROM_END"||d==="FROM_START"?", at1":"",k=e==="FROM_END"||e==="FROM_START"?", at2":"";return[b.provideFunction_("list_sublist_"+d.toLowerCase()+"_"+e.toLowerCase(),`
250
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(source${g}${k})
251
+ local t = {}
252
+ local start = ${gs("source",d,"at1")}
253
+ local finish = ${gs("source",e,"at2")}
254
+ for i = start, finish do
255
+ table.insert(t, source[i])
256
+ end
257
+ return t
258
+ end
259
+ `)+"("+c+(d==="FROM_END"||d==="FROM_START"?", "+f:"")+(e==="FROM_END"||e==="FROM_START"?", "+a:"")+")",Y.HIGH]},lists_indexOf:function(a,b){var c=b.valueToCode(a,"FIND",Y.NONE)||"''",d=b.valueToCode(a,"VALUE",Y.NONE)||"{}";return[(a.getFieldValue("END")==="FIRST"?b.provideFunction_("first_index",`
260
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
261
+ for k, v in ipairs(t) do
262
+ if v == elem then
263
+ return k
264
+ end
265
+ end
266
+ return 0
267
+ end
268
+ `):b.provideFunction_("last_index",`
269
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
270
+ for i = #t, 1, -1 do
271
+ if t[i] == elem then
272
+ return i
273
+ end
274
+ end
275
+ return 0
276
+ end
277
+ `))+"("+d+", "+c+")",Y.HIGH]},lists_isEmpty:function(a,b){return["#"+(b.valueToCode(a,"VALUE",Y.UNARY)||"{}")+" == 0",Y.RELATIONAL]},lists_length:function(a,b){return["#"+(b.valueToCode(a,"VALUE",Y.UNARY)||"{}"),Y.UNARY]},lists_repeat:function(a,b){var c=b.provideFunction_("create_list_repeated",`
278
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(item, count)
279
+ local t = {}
280
+ for i = 1, count do
281
+ table.insert(t, item)
282
+ end
283
+ return t
284
+ end
285
+ `),d=b.valueToCode(a,"ITEM",Y.NONE)||"nil";a=b.valueToCode(a,"NUM",Y.NONE)||"0";return[c+"("+d+", "+a+")",Y.HIGH]},lists_reverse:function(a,b){a=b.valueToCode(a,"LIST",Y.NONE)||"{}";return[b.provideFunction_("list_reverse",`
286
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(input)
287
+ local reversed = {}
288
+ for i = #input, 1, -1 do
289
+ table.insert(reversed, input[i])
290
+ end
291
+ return reversed
292
+ end
293
+ `)+"("+a+")",Y.HIGH]},lists_setIndex:function(a,b){var c=b.valueToCode(a,"LIST",Y.HIGH)||"{}",d=a.getFieldValue("MODE")||"SET",e=a.getFieldValue("WHERE")||"FROM_START",f=b.valueToCode(a,"AT",Y.ADDITIVE)||"1";a=b.valueToCode(a,"TO",Y.NONE)||"Nil";var g="";e!=="LAST"&&e!=="FROM_END"&&e!=="RANDOM"||c.match(/^\w+$/)||(b=b.nameDB_.getDistinctName("tmp_list",$.P.VARIABLE),g=b+" = "+c+"\n",c=b);g=d==="SET"?g+(c+"["+gs(c,e,f)+"] = "+a):g+("table.insert("+c+", "+(gs(c,e,f)+(e==="LAST"?" + 1":""))+", "+a+")");
294
+ return g+"\n"},lists_sort:function(a,b){var c=b.valueToCode(a,"LIST",Y.NONE)||"{}",d=a.getFieldValue("DIRECTION")==="1"?1:-1;a=a.getFieldValue("TYPE");return[b.provideFunction_("list_sort",`
295
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(list, typev, direction)
296
+ local t = {}
297
+ for n,v in pairs(list) do table.insert(t, v) end
298
+ local compareFuncs = {
299
+ NUMERIC = function(a, b)
300
+ return (tonumber(tostring(a)) or 0)
301
+ < (tonumber(tostring(b)) or 0) end,
302
+ TEXT = function(a, b)
303
+ return tostring(a) < tostring(b) end,
304
+ IGNORE_CASE = function(a, b)
305
+ return string.lower(tostring(a)) < string.lower(tostring(b)) end
306
+ }
307
+ local compareTemp = compareFuncs[typev]
308
+ local compare = compareTemp
309
+ if direction == -1
310
+ then compare = function(a, b) return compareTemp(b, a) end
311
+ end
312
+ table.sort(t, compare)
313
+ return t
314
+ end
315
+ `)+"("+c+',"'+a+'", '+d+")",Y.HIGH]},lists_split:function(a,b){var c=b.valueToCode(a,"INPUT",Y.NONE),d=b.valueToCode(a,"DELIM",Y.NONE)||"''";a=a.getFieldValue("MODE");if(a==="SPLIT")c||(c="''"),b=b.provideFunction_("list_string_split",`
316
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(input, delim)
317
+ local t = {}
318
+ local pos = 1
319
+ while true do
320
+ next_delim = string.find(input, delim, pos)
321
+ if next_delim == nil then
322
+ table.insert(t, string.sub(input, pos))
323
+ break
324
+ else
325
+ table.insert(t, string.sub(input, pos, next_delim-1))
326
+ pos = next_delim + #delim
327
+ end
328
+ end
329
+ return t
330
+ end
331
+ `);else if(a==="JOIN")c||(c="{}"),b="table.concat";else throw Error("Unknown mode: "+a);return[b+"("+c+", "+d+")",Y.HIGH]}},ss,ts,us,vs,ws,xs,ys);for(let a in As)zs.forBlock[a]=As[a];var Bs={};Bs.LuaGenerator=rs;Bs.Order=Y;Bs.luaGenerator=zs;$.__chunk_lua=Bs;
332
+ $.__chunk_lua.__namespace__=$;
333
+ return $.__chunk_lua;
370
334
  }));
371
335
 
372
336