blockly 9.3.3 → 10.0.0-beta.0
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/README.md +9 -7
- package/blockly.min.js +1314 -1415
- package/blockly_compressed.js +1067 -1110
- package/blockly_compressed.js.map +1 -1
- package/blocks_compressed.js +120 -136
- package/blocks_compressed.js.map +1 -1
- package/core/block.d.ts +59 -32
- package/core/block_dragger.d.ts +2 -2
- package/core/block_svg.d.ts +38 -67
- package/core/blockly.d.ts +18 -112
- package/core/browser_events.d.ts +1 -2
- package/core/bubble_dragger.d.ts +1 -2
- package/core/{bubble.d.ts → bubble_old.d.ts} +3 -7
- package/core/bubbles/bubble.d.ts +174 -0
- package/core/bubbles/mini_workspace_bubble.d.ts +80 -0
- package/core/bubbles/text_bubble.d.ts +35 -0
- package/core/bubbles/textinput_bubble.d.ts +89 -0
- package/core/bump_objects.d.ts +6 -4
- package/core/connection.d.ts +19 -9
- package/core/connection_db.d.ts +4 -4
- package/core/contextmenu.d.ts +1 -2
- package/core/events/events.d.ts +1 -4
- package/core/events/events_abstract.d.ts +0 -6
- package/core/events/events_block_base.d.ts +0 -6
- package/core/events/events_block_change.d.ts +0 -6
- package/core/events/events_block_create.d.ts +0 -6
- package/core/events/events_block_delete.d.ts +0 -6
- package/core/events/events_block_drag.d.ts +0 -6
- package/core/events/events_block_move.d.ts +21 -7
- package/core/events/events_bubble_open.d.ts +0 -6
- package/core/events/events_click.d.ts +0 -6
- package/core/events/events_comment_base.d.ts +0 -6
- package/core/events/events_comment_change.d.ts +0 -6
- package/core/events/events_comment_create.d.ts +0 -6
- package/core/events/events_comment_move.d.ts +0 -6
- package/core/events/events_marker_move.d.ts +0 -6
- package/core/events/events_selected.d.ts +0 -6
- package/core/events/events_theme_change.d.ts +0 -6
- package/core/events/events_toolbox_item_select.d.ts +0 -6
- package/core/events/events_trashcan_open.d.ts +0 -6
- package/core/events/events_var_base.d.ts +0 -6
- package/core/events/events_var_create.d.ts +0 -6
- package/core/events/events_var_delete.d.ts +0 -6
- package/core/events/events_var_rename.d.ts +0 -6
- package/core/events/events_viewport.d.ts +0 -6
- package/core/events/utils.d.ts +1 -1
- package/core/events/workspace_events.d.ts +1 -16
- package/core/field.d.ts +31 -5
- package/core/field_checkbox.d.ts +1 -1
- package/core/field_colour.d.ts +0 -2
- package/core/field_dropdown.d.ts +11 -13
- package/core/field_image.d.ts +5 -5
- package/core/field_input.d.ts +9 -2
- package/core/field_label.d.ts +3 -1
- package/core/field_number.d.ts +4 -4
- package/core/field_variable.d.ts +5 -5
- package/core/flyout_base.d.ts +23 -25
- package/core/flyout_button.d.ts +9 -9
- package/core/flyout_horizontal.d.ts +1 -1
- package/core/flyout_vertical.d.ts +1 -1
- package/core/generator.d.ts +15 -2
- package/core/gesture.d.ts +58 -41
- package/core/icons/comment_icon.d.ts +108 -0
- package/core/icons/exceptions.d.ts +14 -0
- package/core/icons/icon.d.ts +38 -0
- package/core/icons/icon_types.d.ts +22 -0
- package/core/icons/mutator_icon.d.ts +90 -0
- package/core/icons/registry.d.ts +23 -0
- package/core/icons/warning_icon.d.ts +67 -0
- package/core/icons.d.ts +12 -0
- package/core/inputs/dummy_input.d.ts +20 -0
- package/core/{input.d.ts → inputs/input.d.ts} +20 -13
- package/core/{input_types.d.ts → inputs/input_types.d.ts} +2 -1
- package/core/inputs/statement_input.d.ts +22 -0
- package/core/inputs/value_input.d.ts +20 -0
- package/core/interfaces/i_block_dragger.d.ts +1 -1
- package/core/interfaces/i_bounded_element.d.ts +2 -1
- package/core/interfaces/i_bubble.d.ts +2 -14
- package/core/interfaces/i_has_bubble.d.ts +14 -0
- package/core/interfaces/i_icon.d.ts +75 -0
- package/core/interfaces/i_serializable.d.ts +24 -0
- package/core/keyboard_nav/ast_node.d.ts +15 -15
- package/core/keyboard_nav/basic_cursor.d.ts +2 -2
- package/core/keyboard_nav/marker.d.ts +2 -2
- package/core/main.d.ts +0 -10
- package/core/marker_manager.d.ts +0 -1
- package/core/names.d.ts +4 -4
- package/core/options.d.ts +3 -3
- package/core/procedures.d.ts +1 -4
- package/core/registry.d.ts +5 -0
- package/core/render_management.d.ts +9 -1
- package/core/rendered_connection.d.ts +7 -7
- package/core/renderers/common/block_rendering.d.ts +0 -10
- package/core/renderers/common/constants.d.ts +5 -7
- package/core/renderers/common/drawer.d.ts +7 -2
- package/core/renderers/common/info.d.ts +1 -4
- package/core/renderers/common/marker_svg.d.ts +4 -4
- package/core/renderers/common/renderer.d.ts +0 -9
- package/core/renderers/geras/highlighter.d.ts +1 -1
- package/core/renderers/geras/info.d.ts +1 -1
- package/core/renderers/geras/measurables/inline_input.d.ts +1 -1
- package/core/renderers/geras/measurables/statement_input.d.ts +1 -1
- package/core/renderers/geras/renderer.d.ts +1 -1
- package/core/renderers/measurables/external_value_input.d.ts +1 -1
- package/core/renderers/measurables/field.d.ts +1 -1
- package/core/renderers/measurables/icon.d.ts +5 -1
- package/core/renderers/measurables/inline_input.d.ts +1 -1
- package/core/renderers/measurables/input_connection.d.ts +1 -1
- package/core/renderers/measurables/statement_input.d.ts +1 -1
- package/core/renderers/zelos/constants.d.ts +2 -2
- package/core/renderers/zelos/info.d.ts +2 -2
- package/core/renderers/zelos/marker_svg.d.ts +3 -3
- package/core/renderers/zelos/measurables/inputs.d.ts +1 -1
- package/core/renderers/zelos/path_object.d.ts +3 -3
- package/core/scrollbar.d.ts +0 -2
- package/core/scrollbar_pair.d.ts +0 -2
- package/core/serialization/blocks.d.ts +3 -3
- package/core/serialization/exceptions.d.ts +11 -0
- package/core/shortcut_registry.d.ts +2 -2
- package/core/theme_manager.d.ts +0 -1
- package/core/touch.d.ts +0 -43
- package/core/trashcan.d.ts +19 -21
- package/core/utils/dom.d.ts +2 -2
- package/core/utils/object.d.ts +0 -25
- package/core/utils/rect.d.ts +2 -0
- package/core/utils/style.d.ts +0 -12
- package/core/utils/svg_math.d.ts +0 -8
- package/core/utils/xml.d.ts +15 -22
- package/core/utils.d.ts +0 -138
- package/core/widgetdiv.d.ts +5 -0
- package/core/workspace.d.ts +9 -3
- package/core/workspace_comment.d.ts +3 -3
- package/core/workspace_comment_svg.d.ts +31 -44
- package/core/workspace_dragger.d.ts +1 -4
- package/core/workspace_svg.d.ts +13 -50
- package/core/xml.d.ts +0 -12
- package/core-browser.js +0 -1
- package/core.js +0 -1
- package/dart_compressed.js +124 -159
- package/dart_compressed.js.map +1 -1
- package/javascript_compressed.js +127 -169
- package/javascript_compressed.js.map +1 -1
- package/lua_compressed.js +119 -142
- package/lua_compressed.js.map +1 -1
- package/msg/constants.d.ts +1 -3
- package/msg/msg.d.ts +1 -2
- package/msg/qqq.d.ts +1 -3
- package/msg/synonyms.d.ts +1 -3
- package/package.json +12 -13
- package/php_compressed.js +131 -161
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +118 -149
- package/python_compressed.js.map +1 -1
- package/core/comment.d.ts +0 -115
- package/core/events/events_ui.d.ts +0 -40
- package/core/icon.d.ts +0 -89
- package/core/mutator.d.ts +0 -142
- package/core/renderers/common/debug.d.ts +0 -29
- package/core/renderers/common/debugger.d.ts +0 -117
- package/core/warning.d.ts +0 -53
package/lua_compressed.js
CHANGED
|
@@ -6,31 +6,24 @@
|
|
|
6
6
|
define(["./blockly_compressed.js"], factory);
|
|
7
7
|
} else if (typeof exports === 'object') { // Node.js
|
|
8
8
|
module.exports = factory(require("./blockly_compressed.js"));
|
|
9
|
-
} else { //
|
|
10
|
-
|
|
11
|
-
root.Blockly.Lua = factoryExports.luaGenerator;
|
|
12
|
-
root.Blockly.Lua.__namespace__ = factoryExports.__namespace__;
|
|
9
|
+
} else { // Script
|
|
10
|
+
root.lua = factory(root.Blockly);
|
|
13
11
|
}
|
|
14
12
|
}(this, function(__parent__) {
|
|
15
13
|
var $=__parent__.__namespace__;
|
|
16
|
-
var module$
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
module$exports$Blockly$Lua.luaGenerator.scrub_=function(a,b,c){let d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.module$build$src$core$utils$string.wrap(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e,"-- ")+"\n");for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$build$src$core$input_types.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"-- "))}a=a.nextConnection&&
|
|
23
|
-
a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};var module$exports$Blockly$Lua$colour={};module$exports$Blockly$Lua.luaGenerator.colour_picker=function(a){return[module$exports$Blockly$Lua.luaGenerator.quote_(a.getFieldValue("COLOUR")),module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};module$exports$Blockly$Lua.luaGenerator.colour_random=function(a){return['string.format("#%06x", math.random(0, 2^24 - 1))',module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
24
|
-
module$exports$Blockly$Lua.luaGenerator.colour_rgb=function(a){const b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("colour_rgb",`
|
|
25
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b)
|
|
14
|
+
var addContinueLabel$$module$build$src$generators$lua$loops=function(a,b){return-1!==a.indexOf(CONTINUE_STATEMENT$$module$build$src$generators$lua$loops)?a+b+"::continue::\n":a},Order$$module$build$src$generators$lua={ATOMIC:0,HIGH:1,EXPONENTIATION:2,UNARY:3,MULTIPLICATIVE:4,ADDITIVE:5,CONCATENATION:6,RELATIONAL:7,AND:8,OR:9,NONE:99},LuaGenerator$$module$build$src$generators$lua=class extends $.CodeGenerator$$module$build$src$core$generator{constructor(a){super(null!=a?a:"Lua");this.isInitialized=
|
|
15
|
+
!1;for(const b in Order$$module$build$src$generators$lua)this["ORDER_"+b]=Order$$module$build$src$generators$lua[b];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();
|
|
16
|
+
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){const 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,
|
|
17
|
+
"\\'");return"'"+a+"'"}multiline_quote_(a){return a.split(/\n/g).map(this.quote_).join(" .. '\\n' ..\n")}scrub_(a,b,c){let 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))&&
|
|
18
|
+
(d+=this.prefixLines(e,"-- "))}a=a.nextConnection&&a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c}},luaGenerator$$module$build$src$generators$lua=new LuaGenerator$$module$build$src$generators$lua("Lua"),module$build$src$generators$lua={};module$build$src$generators$lua.Order=Order$$module$build$src$generators$lua;module$build$src$generators$lua.luaGenerator=luaGenerator$$module$build$src$generators$lua;luaGenerator$$module$build$src$generators$lua.forBlock.colour_picker=function(a,b){return[b.quote_(a.getFieldValue("COLOUR")),Order$$module$build$src$generators$lua.ATOMIC]};luaGenerator$$module$build$src$generators$lua.forBlock.colour_random=function(a,b){return['string.format("#%06x", math.random(0, 2^24 - 1))',Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.colour_rgb=function(a,b){const c=b.provideFunction_("colour_rgb",`
|
|
19
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(r, g, b)
|
|
26
20
|
r = math.floor(math.min(100, math.max(0, r)) * 2.55 + .5)
|
|
27
21
|
g = math.floor(math.min(100, math.max(0, g)) * 2.55 + .5)
|
|
28
22
|
b = math.floor(math.min(100, math.max(0, b)) * 2.55 + .5)
|
|
29
23
|
return string.format("#%02x%02x%02x", r, g, b)
|
|
30
24
|
end
|
|
31
|
-
`),
|
|
32
|
-
|
|
33
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio)
|
|
25
|
+
`),d=b.valueToCode(a,"RED",Order$$module$build$src$generators$lua.NONE)||0,e=b.valueToCode(a,"GREEN",Order$$module$build$src$generators$lua.NONE)||0;a=b.valueToCode(a,"BLUE",Order$$module$build$src$generators$lua.NONE)||0;return[c+"("+d+", "+e+", "+a+")",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.colour_blend=function(a,b){const c=b.provideFunction_("colour_blend",`
|
|
26
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio)
|
|
34
27
|
local r1 = tonumber(string.sub(colour1, 2, 3), 16)
|
|
35
28
|
local r2 = tonumber(string.sub(colour2, 2, 3), 16)
|
|
36
29
|
local g1 = tonumber(string.sub(colour1, 4, 5), 16)
|
|
@@ -43,19 +36,19 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(c
|
|
|
43
36
|
local b = math.floor(b1 * (1 - ratio) + b2 * ratio + .5)
|
|
44
37
|
return string.format("#%02x%02x%02x", r, g, b)
|
|
45
38
|
end
|
|
46
|
-
`),
|
|
47
|
-
|
|
48
|
-
function ${
|
|
39
|
+
`),d=b.valueToCode(a,"COLOUR1",Order$$module$build$src$generators$lua.NONE)||"'#000000'",e=b.valueToCode(a,"COLOUR2",Order$$module$build$src$generators$lua.NONE)||"'#000000'";a=b.valueToCode(a,"RATIO",Order$$module$build$src$generators$lua.NONE)||0;return[c+"("+d+", "+e+", "+a+")",Order$$module$build$src$generators$lua.HIGH]};var module$build$src$generators$lua$colour={};luaGenerator$$module$build$src$generators$lua.forBlock.lists_create_empty=function(a,b){return["{}",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.lists_create_with=function(a,b){const 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.NONE)||"None";return["{"+c.join(", ")+"}",Order$$module$build$src$generators$lua.HIGH]};
|
|
40
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.lists_repeat=function(a,b){const c=b.provideFunction_("create_list_repeated",`
|
|
41
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(item, count)
|
|
49
42
|
local t = {}
|
|
50
43
|
for i = 1, count do
|
|
51
44
|
table.insert(t, item)
|
|
52
45
|
end
|
|
53
46
|
return t
|
|
54
47
|
end
|
|
55
|
-
`),
|
|
56
|
-
|
|
57
|
-
module$
|
|
58
|
-
function ${
|
|
48
|
+
`),d=b.valueToCode(a,"ITEM",Order$$module$build$src$generators$lua.NONE)||"None";a=b.valueToCode(a,"NUM",Order$$module$build$src$generators$lua.NONE)||"0";return[c+"("+d+", "+a+")",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.lists_length=function(a,b){return["#"+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua.UNARY)||"{}"),Order$$module$build$src$generators$lua.UNARY]};
|
|
49
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.lists_isEmpty=function(a,b){return["#"+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua.UNARY)||"{}")+" == 0",Order$$module$build$src$generators$lua.RELATIONAL]};
|
|
50
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.lists_indexOf=function(a,b){const c=b.valueToCode(a,"FIND",Order$$module$build$src$generators$lua.NONE)||"''",d=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua.NONE)||"{}";return[("FIRST"===a.getFieldValue("END")?b.provideFunction_("first_index",`
|
|
51
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
|
|
59
52
|
for k, v in ipairs(t) do
|
|
60
53
|
if v == elem then
|
|
61
54
|
return k
|
|
@@ -63,8 +56,8 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t
|
|
|
63
56
|
end
|
|
64
57
|
return 0
|
|
65
58
|
end
|
|
66
|
-
`):
|
|
67
|
-
function ${
|
|
59
|
+
`):b.provideFunction_("last_index",`
|
|
60
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
|
|
68
61
|
for i = #t, 1, -1 do
|
|
69
62
|
if t[i] == elem then
|
|
70
63
|
return i
|
|
@@ -72,26 +65,26 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t
|
|
|
72
65
|
end
|
|
73
66
|
return 0
|
|
74
67
|
end
|
|
75
|
-
`))+"("+
|
|
76
|
-
module$
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
module$
|
|
81
|
-
|
|
82
|
-
module$
|
|
83
|
-
|
|
84
|
-
function ${
|
|
68
|
+
`))+"("+d+", "+c+")",Order$$module$build$src$generators$lua.HIGH]};var getListIndex$$module$build$src$generators$lua$lists=function(a,b,c){return"FIRST"===b?"1":"FROM_END"===b?"#"+a+" + 1 - "+c:"LAST"===b?"#"+a:"RANDOM"===b?"math.random(#"+a+")":c};
|
|
69
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.lists_getIndex=function(a,b){var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START";const e=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua.HIGH)||"({})";if("LAST"!==d&&"FROM_END"!==d&&"RANDOM"!==d||e.match(/^\w+$/)){b=b.valueToCode(a,"AT","GET"===c&&"FROM_END"===d?Order$$module$build$src$generators$lua.ADDITIVE:Order$$module$build$src$generators$lua.NONE)||"1";b=getListIndex$$module$build$src$generators$lua$lists(e,
|
|
70
|
+
d,b);if("GET"===c)return[e+"["+b+"]",Order$$module$build$src$generators$lua.HIGH];d="table.remove("+e+", "+b+")";return"GET_REMOVE"===c?[d,Order$$module$build$src$generators$lua.HIGH]:d+"\n"}if("REMOVE"===c)return c=b.valueToCode(a,"AT","FROM_END"===d?Order$$module$build$src$generators$lua.ADDITIVE:Order$$module$build$src$generators$lua.NONE)||"1",b=b.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE),c=getListIndex$$module$build$src$generators$lua$lists(b,d,c),b+
|
|
71
|
+
" = "+e+"\ntable.remove("+b+", "+c+")\n";a=b.valueToCode(a,"AT",Order$$module$build$src$generators$lua.NONE)||"1";return[("GET"===c?b.provideFunction_("list_get_"+d.toLowerCase(),["function "+b.FUNCTION_NAME_PLACEHOLDER_+"(t"+("FROM_END"===d||"FROM_START"===d?", at)":")")," return t["+getListIndex$$module$build$src$generators$lua$lists("t",d,"at")+"]","end"]):b.provideFunction_("list_remove_"+d.toLowerCase(),["function "+b.FUNCTION_NAME_PLACEHOLDER_+"(t"+("FROM_END"===d||"FROM_START"===d?", at)":
|
|
72
|
+
")")," return table.remove(t, "+getListIndex$$module$build$src$generators$lua$lists("t",d,"at")+")","end"]))+"("+e+("FROM_END"===d||"FROM_START"===d?", "+a:"")+")",Order$$module$build$src$generators$lua.HIGH]};
|
|
73
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.lists_setIndex=function(a,b){let c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua.HIGH)||"{}";const d=a.getFieldValue("MODE")||"SET",e=a.getFieldValue("WHERE")||"FROM_START",f=b.valueToCode(a,"AT",Order$$module$build$src$generators$lua.ADDITIVE)||"1";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$lua.NONE)||"None";let g="";"LAST"!==e&&"FROM_END"!==e&&"RANDOM"!==e||c.match(/^\w+$/)||(b=b.nameDB_.getDistinctName("tmp_list",
|
|
74
|
+
$.NameType$$module$build$src$core$names.VARIABLE),g=b+" = "+c+"\n",c=b);g="SET"===d?g+(c+"["+getListIndex$$module$build$src$generators$lua$lists(c,e,f)+"] = "+a):g+("table.insert("+c+", "+(getListIndex$$module$build$src$generators$lua$lists(c,e,f)+("LAST"===e?" + 1":""))+", "+a+")");return g+"\n"};
|
|
75
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.lists_getSublist=function(a,b){const c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua.NONE)||"{}",d=a.getFieldValue("WHERE1"),e=a.getFieldValue("WHERE2"),f=b.valueToCode(a,"AT1",Order$$module$build$src$generators$lua.NONE)||"1";a=b.valueToCode(a,"AT2",Order$$module$build$src$generators$lua.NONE)||"1";const g="FROM_END"===d||"FROM_START"===d?", at1":"",h="FROM_END"===e||"FROM_START"===e?", at2":"";return[b.provideFunction_("list_sublist_"+
|
|
76
|
+
d.toLowerCase()+"_"+e.toLowerCase(),`
|
|
77
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(source${g}${h})
|
|
85
78
|
local t = {}
|
|
86
|
-
local start = ${module$
|
|
87
|
-
local finish = ${module$
|
|
79
|
+
local start = ${getListIndex$$module$build$src$generators$lua$lists("source",d,"at1")}
|
|
80
|
+
local finish = ${getListIndex$$module$build$src$generators$lua$lists("source",e,"at2")}
|
|
88
81
|
for i = start, finish do
|
|
89
82
|
table.insert(t, source[i])
|
|
90
83
|
end
|
|
91
84
|
return t
|
|
92
85
|
end
|
|
93
|
-
`)+"("+
|
|
94
|
-
function ${
|
|
86
|
+
`)+"("+c+("FROM_END"===d||"FROM_START"===d?", "+f:"")+("FROM_END"===e||"FROM_START"===e?", "+a:"")+")",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.lists_sort=function(a,b){const c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua.NONE)||"{}",d="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[b.provideFunction_("list_sort",`
|
|
87
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(list, typev, direction)
|
|
95
88
|
local t = {}
|
|
96
89
|
for n,v in pairs(list) do table.insert(t, v) end
|
|
97
90
|
local compareFuncs = {
|
|
@@ -111,9 +104,8 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(l
|
|
|
111
104
|
table.sort(t, compare)
|
|
112
105
|
return t
|
|
113
106
|
end
|
|
114
|
-
`)+"("+
|
|
115
|
-
|
|
116
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(input, delim)
|
|
107
|
+
`)+"("+c+',"'+a+'", '+d+")",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.lists_split=function(a,b){let c=b.valueToCode(a,"INPUT",Order$$module$build$src$generators$lua.NONE);const d=b.valueToCode(a,"DELIM",Order$$module$build$src$generators$lua.NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)c||(c="''"),b=b.provideFunction_("list_string_split",`
|
|
108
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(input, delim)
|
|
117
109
|
local t = {}
|
|
118
110
|
local pos = 1
|
|
119
111
|
while true do
|
|
@@ -128,44 +120,39 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(i
|
|
|
128
120
|
end
|
|
129
121
|
return t
|
|
130
122
|
end
|
|
131
|
-
`);else if("JOIN"===a)
|
|
132
|
-
function ${
|
|
123
|
+
`);else if("JOIN"===a)c||(c="{}"),b="table.concat";else throw Error("Unknown mode: "+a);return[b+"("+c+", "+d+")",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.lists_reverse=function(a,b){a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua.NONE)||"{}";return[b.provideFunction_("list_reverse",`
|
|
124
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(input)
|
|
133
125
|
local reversed = {}
|
|
134
126
|
for i = #input, 1, -1 do
|
|
135
127
|
table.insert(reversed, input[i])
|
|
136
128
|
end
|
|
137
129
|
return reversed
|
|
138
130
|
end
|
|
139
|
-
`)+"("+a+")",module$
|
|
140
|
-
|
|
141
|
-
module$
|
|
142
|
-
a),module$
|
|
143
|
-
module$
|
|
144
|
-
module$
|
|
145
|
-
module$
|
|
146
|
-
module$
|
|
147
|
-
|
|
148
|
-
module$
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
c+" do\n"+d+"end\n"};
|
|
152
|
-
module$
|
|
153
|
-
module$
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
module$
|
|
158
|
-
c
|
|
159
|
-
module$
|
|
160
|
-
|
|
161
|
-
module$
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
module$exports$Blockly$Lua.luaGenerator.math_constant=function(a){return{PI:["math.pi",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH],E:["math.exp(1)",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE],SQRT2:["math.sqrt(2)",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH],SQRT1_2:["math.sqrt(1 / 2)",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH],INFINITY:["math.huge",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]}[a.getFieldValue("CONSTANT")]};
|
|
165
|
-
module$exports$Blockly$Lua.luaGenerator.math_number_property=function(a){var b={EVEN:[" % 2 == 0",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],ODD:[" % 2 == 1",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],WHOLE:[" % 1 == 0",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],POSITIVE:[" > 0",
|
|
166
|
-
module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],PRIME:[null,module$exports$Blockly$Lua.luaGenerator.ORDER_NONE,module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
167
|
-
const c=a.getFieldValue("PROPERTY"),[d,e,f]=b[c];b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";if("PRIME"===c)a=module$exports$Blockly$Lua.luaGenerator.provideFunction_("math_isPrime",`
|
|
168
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(n)
|
|
131
|
+
`)+"("+a+")",Order$$module$build$src$generators$lua.HIGH]};var module$build$src$generators$lua$lists={};luaGenerator$$module$build$src$generators$lua.forBlock.controls_if=function(a,b){var c=0;let d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));do{const e=b.valueToCode(a,"IF"+c,Order$$module$build$src$generators$lua.NONE)||"false";let f=b.statementToCode(a,"DO"+c);b.STATEMENT_SUFFIX&&(f=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+f);d+=(0<c?"else":"")+"if "+e+" then\n"+f;c++}while(a.getInput("IF"+c));if(a.getInput("ELSE")||b.STATEMENT_SUFFIX)c=b.statementToCode(a,"ELSE"),
|
|
132
|
+
b.STATEMENT_SUFFIX&&(c=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+c),d+="else\n"+c;return d+"end\n"};luaGenerator$$module$build$src$generators$lua.forBlock.controls_ifelse=luaGenerator$$module$build$src$generators$lua.forBlock.controls_if;
|
|
133
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.logic_compare=function(a,b){const c={EQ:"==",NEQ:"~=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],d=b.valueToCode(a,"A",Order$$module$build$src$generators$lua.RELATIONAL)||"0";a=b.valueToCode(a,"B",Order$$module$build$src$generators$lua.RELATIONAL)||"0";return[d+" "+c+" "+a,Order$$module$build$src$generators$lua.RELATIONAL]};
|
|
134
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.logic_operation=function(a,b){const c="AND"===a.getFieldValue("OP")?"and":"or",d="and"===c?Order$$module$build$src$generators$lua.AND:Order$$module$build$src$generators$lua.OR;let e=b.valueToCode(a,"A",d);a=b.valueToCode(a,"B",d);e||a?(b="and"===c?"true":"false",e||(e=b),a||(a=b)):a=e="false";return[e+" "+c+" "+a,d]};
|
|
135
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.logic_negate=function(a,b){return["not "+(b.valueToCode(a,"BOOL",Order$$module$build$src$generators$lua.UNARY)||"true"),Order$$module$build$src$generators$lua.UNARY]};luaGenerator$$module$build$src$generators$lua.forBlock.logic_boolean=function(a,b){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",Order$$module$build$src$generators$lua.ATOMIC]};
|
|
136
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.logic_null=function(a,b){return["nil",Order$$module$build$src$generators$lua.ATOMIC]};luaGenerator$$module$build$src$generators$lua.forBlock.logic_ternary=function(a,b){const c=b.valueToCode(a,"IF",Order$$module$build$src$generators$lua.AND)||"false",d=b.valueToCode(a,"THEN",Order$$module$build$src$generators$lua.AND)||"nil";a=b.valueToCode(a,"ELSE",Order$$module$build$src$generators$lua.OR)||"nil";return[c+" and "+d+" or "+a,Order$$module$build$src$generators$lua.OR]};
|
|
137
|
+
var module$build$src$generators$lua$logic={};var CONTINUE_STATEMENT$$module$build$src$generators$lua$loops="goto continue\n";
|
|
138
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.controls_repeat_ext=function(a,b){let c;c=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):b.valueToCode(a,"TIMES",Order$$module$build$src$generators$lua.NONE)||"0";c=$.isNumber$$module$build$src$core$utils$string(c)?parseInt(c,10):"math.floor("+c+")";let 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",$.NameType$$module$build$src$core$names.VARIABLE)+
|
|
139
|
+
" = 1, "+c+" do\n"+d+"end\n"};luaGenerator$$module$build$src$generators$lua.forBlock.controls_repeat=luaGenerator$$module$build$src$generators$lua.forBlock.controls_repeat_ext;
|
|
140
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.controls_whileUntil=function(a,b){const c="UNTIL"===a.getFieldValue("MODE");let d=b.valueToCode(a,"BOOL",c?Order$$module$build$src$generators$lua.UNARY:Order$$module$build$src$generators$lua.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"+e+"end\n"};
|
|
141
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.controls_for=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$lua.NONE)||"0",e=b.valueToCode(a,"TO",Order$$module$build$src$generators$lua.NONE)||"0",f=b.valueToCode(a,"BY",Order$$module$build$src$generators$lua.NONE)||"1";let g=b.statementToCode(a,"DO");g=b.addLoopTrap(g,a);g=addContinueLabel$$module$build$src$generators$lua$loops(g,
|
|
142
|
+
b.INDENT);a="";let h;$.isNumber$$module$build$src$core$utils$string(d)&&$.isNumber$$module$build$src$core$utils$string(e)&&$.isNumber$$module$build$src$core$utils$string(f)?h=(Number(d)<=Number(e)?"":"-")+Math.abs(Number(f)):(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");
|
|
143
|
+
return a+("for "+c+" = "+d+", "+e+", "+h)+(" do\n"+g+"end\n")};luaGenerator$$module$build$src$generators$lua.forBlock.controls_forEach=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),d=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua.NONE)||"{}";let 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"};
|
|
144
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.controls_flow_statements=function(a,b){let 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){const 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.");
|
|
145
|
+
};var module$build$src$generators$lua$loops={};luaGenerator$$module$build$src$generators$lua.forBlock.math_number=function(a,b){a=Number(a.getFieldValue("NUM"));return[a,0>a?Order$$module$build$src$generators$lua.UNARY:Order$$module$build$src$generators$lua.ATOMIC]};
|
|
146
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.math_arithmetic=function(a,b){var c={ADD:[" + ",Order$$module$build$src$generators$lua.ADDITIVE],MINUS:[" - ",Order$$module$build$src$generators$lua.ADDITIVE],MULTIPLY:[" * ",Order$$module$build$src$generators$lua.MULTIPLICATIVE],DIVIDE:[" / ",Order$$module$build$src$generators$lua.MULTIPLICATIVE],POWER:[" ^ ",Order$$module$build$src$generators$lua.EXPONENTIATION]}[a.getFieldValue("OP")];const d=c[0];c=c[1];const e=b.valueToCode(a,"A",c)||"0";
|
|
147
|
+
a=b.valueToCode(a,"B",c)||"0";return[e+d+a,c]};
|
|
148
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.math_single=function(a,b){var c=a.getFieldValue("OP");if("NEG"===c)return a=b.valueToCode(a,"NUM",Order$$module$build$src$generators$lua.UNARY)||"0",["-"+a,Order$$module$build$src$generators$lua.UNARY];if("POW10"===c)return a=b.valueToCode(a,"NUM",Order$$module$build$src$generators$lua.EXPONENTIATION)||"0",["10 ^ "+a,Order$$module$build$src$generators$lua.EXPONENTIATION];a="ROUND"===c?b.valueToCode(a,"NUM",Order$$module$build$src$generators$lua.ADDITIVE)||
|
|
149
|
+
"0":b.valueToCode(a,"NUM",Order$$module$build$src$generators$lua.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)";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;
|
|
150
|
+
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: "+c);}return[c,Order$$module$build$src$generators$lua.HIGH]};
|
|
151
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.math_constant=function(a,b){return{PI:["math.pi",Order$$module$build$src$generators$lua.HIGH],E:["math.exp(1)",Order$$module$build$src$generators$lua.HIGH],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",Order$$module$build$src$generators$lua.MULTIPLICATIVE],SQRT2:["math.sqrt(2)",Order$$module$build$src$generators$lua.HIGH],SQRT1_2:["math.sqrt(1 / 2)",Order$$module$build$src$generators$lua.HIGH],INFINITY:["math.huge",Order$$module$build$src$generators$lua.HIGH]}[a.getFieldValue("CONSTANT")]};
|
|
152
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.math_number_property=function(a,b){var c={EVEN:[" % 2 == 0",Order$$module$build$src$generators$lua.MULTIPLICATIVE,Order$$module$build$src$generators$lua.RELATIONAL],ODD:[" % 2 == 1",Order$$module$build$src$generators$lua.MULTIPLICATIVE,Order$$module$build$src$generators$lua.RELATIONAL],WHOLE:[" % 1 == 0",Order$$module$build$src$generators$lua.MULTIPLICATIVE,Order$$module$build$src$generators$lua.RELATIONAL],POSITIVE:[" > 0",Order$$module$build$src$generators$lua.RELATIONAL,
|
|
153
|
+
Order$$module$build$src$generators$lua.RELATIONAL],NEGATIVE:[" < 0",Order$$module$build$src$generators$lua.RELATIONAL,Order$$module$build$src$generators$lua.RELATIONAL],DIVISIBLE_BY:[null,Order$$module$build$src$generators$lua.MULTIPLICATIVE,Order$$module$build$src$generators$lua.RELATIONAL],PRIME:[null,Order$$module$build$src$generators$lua.NONE,Order$$module$build$src$generators$lua.HIGH]};const d=a.getFieldValue("PROPERTY"),[e,f,g]=c[d];c=b.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";if("PRIME"===
|
|
154
|
+
d)a=b.provideFunction_("math_isPrime",`
|
|
155
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(n)
|
|
169
156
|
-- https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
170
157
|
if n == 2 or n == 3 then
|
|
171
158
|
return true
|
|
@@ -183,18 +170,18 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(n
|
|
|
183
170
|
end
|
|
184
171
|
return true
|
|
185
172
|
end
|
|
186
|
-
`)+"("+
|
|
187
|
-
module$
|
|
188
|
-
|
|
189
|
-
function ${
|
|
173
|
+
`)+"("+c+")";else if("DIVISIBLE_BY"===d){a=b.valueToCode(a,"DIVISOR",Order$$module$build$src$generators$lua.MULTIPLICATIVE)||"0";if("0"===a)return["nil",Order$$module$build$src$generators$lua.ATOMIC];a=c+" % "+a+" == 0"}else a=c+e;return[a,g]};
|
|
174
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.math_change=function(a,b){const c=b.valueToCode(a,"DELTA",Order$$module$build$src$generators$lua.ADDITIVE)||"0";a=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);return a+" = "+a+" + "+c+"\n"};luaGenerator$$module$build$src$generators$lua.forBlock.math_round=luaGenerator$$module$build$src$generators$lua.forBlock.math_single;luaGenerator$$module$build$src$generators$lua.forBlock.math_trig=luaGenerator$$module$build$src$generators$lua.forBlock.math_single;
|
|
175
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.math_on_list=function(a,b){function c(){return b.provideFunction_("math_sum",`
|
|
176
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
190
177
|
local result = 0
|
|
191
178
|
for _, v in ipairs(t) do
|
|
192
179
|
result = result + v
|
|
193
180
|
end
|
|
194
181
|
return result
|
|
195
182
|
end
|
|
196
|
-
`)}var
|
|
197
|
-
function ${
|
|
183
|
+
`)}var d=a.getFieldValue("OP");a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$lua.NONE)||"{}";switch(d){case "SUM":d=c();break;case "MIN":d=b.provideFunction_("math_min",`
|
|
184
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
198
185
|
if #t == 0 then
|
|
199
186
|
return 0
|
|
200
187
|
end
|
|
@@ -206,15 +193,15 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t
|
|
|
206
193
|
end
|
|
207
194
|
return result
|
|
208
195
|
end
|
|
209
|
-
`);break;case "AVERAGE":
|
|
210
|
-
function ${
|
|
196
|
+
`);break;case "AVERAGE":d=b.provideFunction_("math_average",`
|
|
197
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
211
198
|
if #t == 0 then
|
|
212
199
|
return 0
|
|
213
200
|
end
|
|
214
|
-
return ${
|
|
201
|
+
return ${c()}(t) / #t
|
|
215
202
|
end
|
|
216
|
-
`);break;case "MAX":
|
|
217
|
-
function ${
|
|
203
|
+
`);break;case "MAX":d=b.provideFunction_("math_max",`
|
|
204
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
218
205
|
if #t == 0 then
|
|
219
206
|
return 0
|
|
220
207
|
end
|
|
@@ -226,8 +213,8 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t
|
|
|
226
213
|
end
|
|
227
214
|
return result
|
|
228
215
|
end
|
|
229
|
-
`);break;case "MEDIAN":
|
|
230
|
-
function ${
|
|
216
|
+
`);break;case "MEDIAN":d=b.provideFunction_("math_median",`
|
|
217
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
231
218
|
-- Source: http://lua-users.org/wiki/SimpleStats
|
|
232
219
|
if #t == 0 then
|
|
233
220
|
return 0
|
|
@@ -245,8 +232,8 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t
|
|
|
245
232
|
return temp[math.ceil(#temp / 2)]
|
|
246
233
|
end
|
|
247
234
|
end
|
|
248
|
-
`);break;case "MODE":
|
|
249
|
-
function ${
|
|
235
|
+
`);break;case "MODE":d=b.provideFunction_("math_modes",`
|
|
236
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
250
237
|
-- Source: http://lua-users.org/wiki/SimpleStats
|
|
251
238
|
local counts = {}
|
|
252
239
|
for _, v in ipairs(t) do
|
|
@@ -270,14 +257,14 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t
|
|
|
270
257
|
end
|
|
271
258
|
return temp
|
|
272
259
|
end
|
|
273
|
-
`);break;case "STD_DEV":
|
|
274
|
-
function ${
|
|
260
|
+
`);break;case "STD_DEV":d=b.provideFunction_("math_standard_deviation",`
|
|
261
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
275
262
|
local m
|
|
276
263
|
local vm
|
|
277
264
|
local total = 0
|
|
278
265
|
local count = 0
|
|
279
266
|
local result
|
|
280
|
-
m = #t == 0 and 0 or ${
|
|
267
|
+
m = #t == 0 and 0 or ${c()}(t) / #t
|
|
281
268
|
for _, v in ipairs(t) do
|
|
282
269
|
if type(v) == 'number' then
|
|
283
270
|
vm = v - m
|
|
@@ -288,62 +275,55 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t
|
|
|
288
275
|
result = math.sqrt(total / (count-1))
|
|
289
276
|
return result
|
|
290
277
|
end
|
|
291
|
-
`);break;case "RANDOM":
|
|
292
|
-
function ${
|
|
278
|
+
`);break;case "RANDOM":d=b.provideFunction_("math_random_list",`
|
|
279
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
293
280
|
if #t == 0 then
|
|
294
281
|
return nil
|
|
295
282
|
end
|
|
296
283
|
return t[math.random(#t)]
|
|
297
284
|
end
|
|
298
|
-
`);break;default:throw Error("Unknown operator: "+
|
|
299
|
-
module$
|
|
300
|
-
module$
|
|
301
|
-
module$
|
|
302
|
-
module$
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return
|
|
306
|
-
module$
|
|
307
|
-
module$
|
|
308
|
-
module$
|
|
309
|
-
|
|
310
|
-
module$
|
|
311
|
-
|
|
312
|
-
"''";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ADD1",module$exports$Blockly$Lua.luaGenerator.ORDER_CONCATENATION)||"''";return[b+" .. "+a,module$exports$Blockly$Lua.luaGenerator.ORDER_CONCATENATION]}b=[];for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";return["table.concat({"+b.join(", ")+"})",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
313
|
-
module$exports$Blockly$Lua.luaGenerator.text_append=function(a){const b=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_CONCATENATION)||"''";return b+" = "+b+" .. "+a+"\n"};
|
|
314
|
-
module$exports$Blockly$Lua.luaGenerator.text_length=function(a){return["#"+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY)||"''"),module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY]};module$exports$Blockly$Lua.luaGenerator.text_isEmpty=function(a){return["#"+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY)||"''")+" == 0",module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL]};
|
|
315
|
-
module$exports$Blockly$Lua.luaGenerator.text_indexOf=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"FIND",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''",c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";return[("FIRST"===a.getFieldValue("END")?module$exports$Blockly$Lua.luaGenerator.provideFunction_("firstIndexOf",`
|
|
316
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
|
|
285
|
+
`);break;default:throw Error("Unknown operator: "+d);}return[d+"("+a+")",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.math_modulo=function(a,b){const c=b.valueToCode(a,"DIVIDEND",Order$$module$build$src$generators$lua.MULTIPLICATIVE)||"0";a=b.valueToCode(a,"DIVISOR",Order$$module$build$src$generators$lua.MULTIPLICATIVE)||"0";return[c+" % "+a,Order$$module$build$src$generators$lua.MULTIPLICATIVE]};
|
|
286
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.math_constrain=function(a,b){const c=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua.NONE)||"0",d=b.valueToCode(a,"LOW",Order$$module$build$src$generators$lua.NONE)||"-math.huge";a=b.valueToCode(a,"HIGH",Order$$module$build$src$generators$lua.NONE)||"math.huge";return["math.min(math.max("+c+", "+d+"), "+a+")",Order$$module$build$src$generators$lua.HIGH]};
|
|
287
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.math_random_int=function(a,b){const c=b.valueToCode(a,"FROM",Order$$module$build$src$generators$lua.NONE)||"0";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$lua.NONE)||"0";return["math.random("+c+", "+a+")",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.math_random_float=function(a,b){return["math.random()",Order$$module$build$src$generators$lua.HIGH]};
|
|
288
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.math_atan2=function(a,b){const c=b.valueToCode(a,"X",Order$$module$build$src$generators$lua.NONE)||"0";return["math.deg(math.atan2("+(b.valueToCode(a,"Y",Order$$module$build$src$generators$lua.NONE)||"0")+", "+c+"))",Order$$module$build$src$generators$lua.HIGH]};var module$build$src$generators$lua$math={};luaGenerator$$module$build$src$generators$lua.forBlock.procedures_defreturn=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);var 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));let e="";b.INFINITE_LOOP_TRAP&&(e=b.prefixLines(b.injectId(b.INFINITE_LOOP_TRAP,a),b.INDENT));let f=b.statementToCode(a,"STACK"),g=b.valueToCode(a,"RETURN",
|
|
289
|
+
Order$$module$build$src$generators$lua.NONE)||"",h="";f&&g&&(h=d);g?g=b.INDENT+"return "+g+"\n":f||(f="");const k=[],l=a.getVars();for(let n=0;n<l.length;n++)k[n]=b.nameDB_.getName(l[n],$.NameType$$module$build$src$core$names.VARIABLE);d="function "+c+"("+k.join(", ")+")\n"+d+e+f+h+g+"end\n";d=b.scrub_(a,d);b.definitions_["%"+c]=d;return null};luaGenerator$$module$build$src$generators$lua.forBlock.procedures_defnoreturn=luaGenerator$$module$build$src$generators$lua.forBlock.procedures_defreturn;
|
|
290
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.procedures_callreturn=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),d=[],e=a.getVars();for(let f=0;f<e.length;f++)d[f]=b.valueToCode(a,"ARG"+f,Order$$module$build$src$generators$lua.NONE)||"nil";return[c+"("+d.join(", ")+")",Order$$module$build$src$generators$lua.HIGH]};
|
|
291
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.procedures_callnoreturn=function(a,b){return b.forBlock.procedures_callreturn(a,b)[0]+"\n"};
|
|
292
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.procedures_ifreturn=function(a,b){let c="if "+(b.valueToCode(a,"CONDITION",Order$$module$build$src$generators$lua.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.NONE)||"nil",c+=b.INDENT+"return "+a+"\n"):c+=b.INDENT+"return\n";return c+"end\n"};var module$build$src$generators$lua$procedures={};luaGenerator$$module$build$src$generators$lua.forBlock.text=function(a,b){return[b.quote_(a.getFieldValue("TEXT")),Order$$module$build$src$generators$lua.ATOMIC]};luaGenerator$$module$build$src$generators$lua.forBlock.text_multiline=function(a,b){a=b.multiline_quote_(a.getFieldValue("TEXT"));b=-1!==a.indexOf("..")?Order$$module$build$src$generators$lua.CONCATENATION:Order$$module$build$src$generators$lua.ATOMIC;return[a,b]};
|
|
293
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.text_join=function(a,b){if(0===a.itemCount_)return["''",Order$$module$build$src$generators$lua.ATOMIC];if(1===a.itemCount_)return["tostring("+(b.valueToCode(a,"ADD0",Order$$module$build$src$generators$lua.NONE)||"''")+")",Order$$module$build$src$generators$lua.HIGH];if(2===a.itemCount_){var c=b.valueToCode(a,"ADD0",Order$$module$build$src$generators$lua.CONCATENATION)||"''";a=b.valueToCode(a,"ADD1",Order$$module$build$src$generators$lua.CONCATENATION)||
|
|
294
|
+
"''";return[c+" .. "+a,Order$$module$build$src$generators$lua.CONCATENATION]}c=[];for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,Order$$module$build$src$generators$lua.NONE)||"''";return["table.concat({"+c.join(", ")+"})",Order$$module$build$src$generators$lua.HIGH]};
|
|
295
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.text_append=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua.CONCATENATION)||"''";return c+" = "+c+" .. "+a+"\n"};luaGenerator$$module$build$src$generators$lua.forBlock.text_length=function(a,b){return["#"+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua.UNARY)||"''"),Order$$module$build$src$generators$lua.UNARY]};
|
|
296
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.text_isEmpty=function(a,b){return["#"+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua.UNARY)||"''")+" == 0",Order$$module$build$src$generators$lua.RELATIONAL]};
|
|
297
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.text_indexOf=function(a,b){const c=b.valueToCode(a,"FIND",Order$$module$build$src$generators$lua.NONE)||"''",d=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua.NONE)||"''";return[("FIRST"===a.getFieldValue("END")?b.provideFunction_("firstIndexOf",`
|
|
298
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
|
|
317
299
|
local i = string.find(str, substr, 1, true)
|
|
318
300
|
if i == nil then
|
|
319
301
|
return 0
|
|
320
302
|
end
|
|
321
303
|
return i
|
|
322
304
|
end
|
|
323
|
-
`):
|
|
324
|
-
function ${
|
|
305
|
+
`):b.provideFunction_("lastIndexOf",`
|
|
306
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
|
|
325
307
|
local i = string.find(string.reverse(str), string.reverse(substr), 1, true)
|
|
326
308
|
if i then
|
|
327
309
|
return #str + 2 - i - #substr
|
|
328
310
|
end
|
|
329
311
|
return 0
|
|
330
312
|
end
|
|
331
|
-
`))+"("+
|
|
332
|
-
|
|
333
|
-
`
|
|
334
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str)
|
|
313
|
+
`))+"("+d+", "+c+")",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.text_charAt=function(a,b){var c=a.getFieldValue("WHERE")||"FROM_START";const d=b.valueToCode(a,"AT","FROM_END"===c?Order$$module$build$src$generators$lua.UNARY:Order$$module$build$src$generators$lua.NONE)||"1";a=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua.NONE)||"''";if("RANDOM"===c)b=b.provideFunction_("text_random_letter",`
|
|
314
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(str)
|
|
335
315
|
local index = math.random(string.len(str))
|
|
336
316
|
return string.sub(str, index, index)
|
|
337
317
|
end
|
|
338
|
-
`)+"("+a+")";else{if("FIRST"===
|
|
339
|
-
function ${
|
|
318
|
+
`)+"("+a+")";else{if("FIRST"===c)c="1";else if("LAST"===c)c="-1";else if("FROM_START"===c)c=d;else if("FROM_END"===c)c="-"+d;else throw Error("Unhandled option (text_charAt).");b=c.match(/^-?\w*$/)?"string.sub("+a+", "+c+", "+c+")":b.provideFunction_("text_char_at",`
|
|
319
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(str, index)
|
|
340
320
|
return string.sub(str, index, index)
|
|
341
321
|
end
|
|
342
|
-
`)+"("+a+", "+
|
|
343
|
-
module$
|
|
344
|
-
|
|
345
|
-
module$
|
|
346
|
-
function ${
|
|
322
|
+
`)+"("+a+", "+c+")"}return[b,Order$$module$build$src$generators$lua.HIGH]};
|
|
323
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.text_getSubstring=function(a,b){const c=b.valueToCode(a,"STRING",Order$$module$build$src$generators$lua.NONE)||"''";var d=a.getFieldValue("WHERE1"),e=b.valueToCode(a,"AT1","FROM_END"===d?Order$$module$build$src$generators$lua.UNARY:Order$$module$build$src$generators$lua.NONE)||"1";if("FIRST"===d)d=1;else if("FROM_START"===d)d=e;else if("FROM_END"===d)d="-"+e;else throw Error("Unhandled option (text_getSubstring)");e=a.getFieldValue("WHERE2");
|
|
324
|
+
a=b.valueToCode(a,"AT2","FROM_END"===e?Order$$module$build$src$generators$lua.UNARY:Order$$module$build$src$generators$lua.NONE)||"1";if("LAST"===e)a=-1;else if("FROM_START"!==e)if("FROM_END"===e)a="-"+a;else throw Error("Unhandled option (text_getSubstring)");return["string.sub("+c+", "+d+", "+a+")",Order$$module$build$src$generators$lua.HIGH]};
|
|
325
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.text_changeCase=function(a,b){const c=a.getFieldValue("CASE");a=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua.NONE)||"''";let d;"UPPERCASE"===c?d="string.upper":"LOWERCASE"===c?d="string.lower":"TITLECASE"===c&&(d=b.provideFunction_("text_titlecase",`
|
|
326
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(str)
|
|
347
327
|
local buf = {}
|
|
348
328
|
local inWord = false
|
|
349
329
|
for i = 1, #str do
|
|
@@ -360,17 +340,16 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(s
|
|
|
360
340
|
end
|
|
361
341
|
return table.concat(buf)
|
|
362
342
|
end
|
|
363
|
-
`));return[
|
|
364
|
-
module$
|
|
365
|
-
|
|
366
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(msg)
|
|
343
|
+
`));return[d+"("+a+")",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.text_trim=function(a,b){const c={LEFT:"^%s*(,-)",RIGHT:"(.-)%s*$",BOTH:"^%s*(.-)%s*$"}[a.getFieldValue("MODE")];return["string.gsub("+(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua.NONE)||"''")+', "'+c+'", "%1")',Order$$module$build$src$generators$lua.HIGH]};
|
|
344
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.text_print=function(a,b){return"print("+(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua.NONE)||"''")+")\n"};luaGenerator$$module$build$src$generators$lua.forBlock.text_prompt_ext=function(a,b){let c;c=a.getField("TEXT")?b.quote_(a.getFieldValue("TEXT")):b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua.NONE)||"''";b=b.provideFunction_("text_prompt",`
|
|
345
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(msg)
|
|
367
346
|
io.write(msg)
|
|
368
347
|
io.flush()
|
|
369
348
|
return io.read()
|
|
370
349
|
end
|
|
371
|
-
`)+"("+
|
|
372
|
-
module$
|
|
373
|
-
function ${
|
|
350
|
+
`)+"("+c+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="tonumber("+b+", 10)");return[b,Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.text_prompt=luaGenerator$$module$build$src$generators$lua.forBlock.text_prompt_ext;
|
|
351
|
+
luaGenerator$$module$build$src$generators$lua.forBlock.text_count=function(a,b){const c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua.NONE)||"''";a=b.valueToCode(a,"SUB",Order$$module$build$src$generators$lua.NONE)||"''";return[b.provideFunction_("text_count",`
|
|
352
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle)
|
|
374
353
|
if #needle == 0 then
|
|
375
354
|
return #haystack + 1
|
|
376
355
|
end
|
|
@@ -386,10 +365,8 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(h
|
|
|
386
365
|
end
|
|
387
366
|
return count
|
|
388
367
|
end
|
|
389
|
-
`)+"("+
|
|
390
|
-
|
|
391
|
-
`
|
|
392
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement)
|
|
368
|
+
`)+"("+c+", "+a+")",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.text_replace=function(a,b){const c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua.NONE)||"''",d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$lua.NONE)||"''";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$lua.NONE)||"''";return[b.provideFunction_("text_replace",`
|
|
369
|
+
function ${b.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement)
|
|
393
370
|
local buf = {}
|
|
394
371
|
local i = 1
|
|
395
372
|
while i <= #haystack do
|
|
@@ -405,10 +382,10 @@ function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(h
|
|
|
405
382
|
end
|
|
406
383
|
return table.concat(buf)
|
|
407
384
|
end
|
|
408
|
-
`)+"("+
|
|
409
|
-
module$
|
|
410
|
-
module$
|
|
411
|
-
return module$
|
|
385
|
+
`)+"("+c+", "+d+", "+a+")",Order$$module$build$src$generators$lua.HIGH]};luaGenerator$$module$build$src$generators$lua.forBlock.text_reverse=function(a,b){return["string.reverse("+(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$lua.NONE)||"''")+")",Order$$module$build$src$generators$lua.HIGH]};var module$build$src$generators$lua$text={};luaGenerator$$module$build$src$generators$lua.forBlock.variables_get=function(a,b){return[b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),Order$$module$build$src$generators$lua.ATOMIC]};luaGenerator$$module$build$src$generators$lua.forBlock.variables_set=function(a,b){const c=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$lua.NONE)||"0";return b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+c+"\n"};
|
|
386
|
+
var module$build$src$generators$lua$variables={};luaGenerator$$module$build$src$generators$lua.forBlock.variables_get_dynamic=luaGenerator$$module$build$src$generators$lua.forBlock.variables_get;luaGenerator$$module$build$src$generators$lua.forBlock.variables_set_dynamic=luaGenerator$$module$build$src$generators$lua.forBlock.variables_set;var module$build$src$generators$lua$variables_dynamic={};var module$build$src$generators$lua$all={};module$build$src$generators$lua$all.Order=Order$$module$build$src$generators$lua;module$build$src$generators$lua$all.luaGenerator=luaGenerator$$module$build$src$generators$lua;
|
|
387
|
+
module$build$src$generators$lua$all.__namespace__=$;
|
|
388
|
+
return module$build$src$generators$lua$all;
|
|
412
389
|
}));
|
|
413
390
|
|
|
414
391
|
|