blockly 9.3.0-beta.0 → 9.3.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/blockly.min.js +1674 -1520
- package/blockly_compressed.js +1313 -1152
- package/blockly_compressed.js.map +1 -1
- package/blocks_compressed.js +166 -173
- package/blocks_compressed.js.map +1 -1
- package/core/any_aliases.d.ts +5 -0
- package/core/block.d.ts +49 -17
- package/core/block_animations.d.ts +0 -4
- package/core/block_drag_surface.d.ts +135 -0
- package/core/block_dragger.d.ts +2 -7
- package/core/block_svg.d.ts +72 -9
- package/core/blockly.d.ts +29 -58
- package/core/blockly_options.d.ts +0 -2
- package/core/blocks.d.ts +0 -2
- package/core/browser_events.d.ts +0 -9
- package/core/bubble.d.ts +6 -4
- package/core/bubble_dragger.d.ts +2 -3
- package/core/bump_objects.d.ts +0 -3
- package/core/clipboard.d.ts +0 -3
- package/core/comment.d.ts +6 -10
- package/core/common.d.ts +0 -12
- package/core/component_manager.d.ts +0 -2
- package/core/connection.d.ts +19 -6
- package/core/connection_checker.d.ts +1 -3
- package/core/connection_db.d.ts +0 -2
- package/core/connection_type.d.ts +0 -2
- package/core/constants.d.ts +0 -4
- package/core/contextmenu.d.ts +0 -11
- package/core/contextmenu_items.d.ts +0 -27
- package/core/contextmenu_registry.d.ts +0 -2
- package/core/css.d.ts +0 -2
- package/core/delete_area.d.ts +0 -2
- package/core/dialog.d.ts +0 -6
- package/core/drag_target.d.ts +0 -2
- package/core/events/events_abstract.d.ts +0 -3
- package/core/events/events_block_base.d.ts +0 -2
- package/core/events/events_block_change.d.ts +0 -2
- package/core/events/events_block_create.d.ts +0 -2
- package/core/events/events_block_delete.d.ts +0 -2
- package/core/events/events_block_drag.d.ts +0 -2
- package/core/events/events_block_move.d.ts +0 -2
- package/core/events/events_bubble_open.d.ts +0 -2
- package/core/events/events_click.d.ts +0 -2
- package/core/events/events_comment_base.d.ts +0 -2
- package/core/events/events_comment_change.d.ts +0 -2
- package/core/events/events_comment_create.d.ts +0 -2
- package/core/events/events_comment_delete.d.ts +0 -2
- package/core/events/events_comment_move.d.ts +0 -2
- package/core/events/events_marker_move.d.ts +0 -2
- package/core/events/events_selected.d.ts +0 -2
- package/core/events/events_theme_change.d.ts +0 -2
- package/core/events/events_toolbox_item_select.d.ts +0 -2
- package/core/events/events_trashcan_open.d.ts +0 -2
- package/core/events/events_ui.d.ts +0 -1
- package/core/events/events_ui_base.d.ts +0 -2
- package/core/events/events_var_base.d.ts +0 -2
- package/core/events/events_var_create.d.ts +0 -2
- package/core/events/events_viewport.d.ts +0 -2
- package/core/events/utils.d.ts +0 -73
- package/core/events/workspace_events.d.ts +0 -2
- package/core/extensions.d.ts +0 -8
- package/core/field.d.ts +16 -15
- package/core/field_angle.d.ts +60 -50
- package/core/field_checkbox.d.ts +22 -10
- package/core/field_colour.d.ts +55 -42
- package/core/field_dropdown.d.ts +34 -18
- package/core/field_image.d.ts +9 -12
- package/core/field_input.d.ts +34 -11
- package/core/field_label.d.ts +7 -10
- package/core/field_label_serializable.d.ts +4 -6
- package/core/field_multilineinput.d.ts +34 -12
- package/core/field_number.d.ts +27 -19
- package/core/field_registry.d.ts +0 -3
- package/core/field_textinput.d.ts +28 -12
- package/core/field_variable.d.ts +28 -16
- package/core/flyout_base.d.ts +5 -6
- package/core/flyout_button.d.ts +2 -2
- package/core/flyout_horizontal.d.ts +0 -2
- package/core/flyout_metrics_manager.d.ts +0 -2
- package/core/flyout_vertical.d.ts +0 -2
- package/core/generator.d.ts +0 -1
- package/core/gesture.d.ts +4 -17
- package/core/grid.d.ts +0 -2
- package/core/icon.d.ts +0 -2
- package/core/inject.d.ts +0 -1
- package/core/input.d.ts +0 -3
- package/core/input_types.d.ts +0 -2
- package/core/insertion_marker_manager.d.ts +6 -6
- package/core/interfaces/i_ast_node_location.d.ts +0 -2
- package/core/interfaces/i_ast_node_location_svg.d.ts +0 -2
- package/core/interfaces/i_ast_node_location_with_block.d.ts +0 -2
- package/core/interfaces/i_autohideable.d.ts +0 -2
- package/core/interfaces/i_block_dragger.d.ts +1 -3
- package/core/interfaces/i_bounded_element.d.ts +0 -2
- package/core/interfaces/i_bubble.d.ts +6 -4
- package/core/interfaces/i_collapsible_toolbox_item.d.ts +0 -2
- package/core/interfaces/i_component.d.ts +0 -2
- package/core/interfaces/i_connection_checker.d.ts +0 -2
- package/core/interfaces/i_contextmenu.d.ts +0 -1
- package/core/interfaces/i_copyable.d.ts +3 -2
- package/core/interfaces/i_deletable.d.ts +0 -2
- package/core/interfaces/i_delete_area.d.ts +0 -2
- package/core/interfaces/i_drag_target.d.ts +0 -2
- package/core/interfaces/i_draggable.d.ts +0 -2
- package/core/interfaces/i_flyout.d.ts +0 -2
- package/core/interfaces/i_keyboard_accessible.d.ts +0 -2
- package/core/interfaces/i_legacy_procedure_blocks.d.ts +34 -0
- package/core/interfaces/i_metrics_manager.d.ts +0 -2
- package/core/interfaces/i_movable.d.ts +0 -2
- package/core/interfaces/i_positionable.d.ts +0 -2
- package/core/interfaces/i_procedure_model.d.ts +0 -5
- package/core/interfaces/i_registrable.d.ts +0 -2
- package/core/interfaces/i_selectable.d.ts +0 -2
- package/core/interfaces/i_selectable_toolbox_item.d.ts +4 -2
- package/core/interfaces/i_serializer.d.ts +0 -2
- package/core/interfaces/i_styleable.d.ts +0 -2
- package/core/interfaces/i_toolbox.d.ts +0 -2
- package/core/interfaces/i_toolbox_item.d.ts +0 -2
- package/core/interfaces/i_variable_backed_parameter_model.d.ts +17 -0
- package/core/internal_constants.d.ts +0 -5
- package/core/keyboard_nav/ast_node.d.ts +0 -3
- package/core/keyboard_nav/basic_cursor.d.ts +0 -3
- package/core/keyboard_nav/cursor.d.ts +0 -3
- package/core/keyboard_nav/marker.d.ts +0 -2
- package/core/keyboard_nav/tab_navigate_cursor.d.ts +0 -2
- package/core/marker_manager.d.ts +0 -2
- package/core/menu.d.ts +0 -2
- package/core/menuitem.d.ts +0 -2
- package/core/metrics_manager.d.ts +0 -2
- package/core/mutator.d.ts +0 -2
- package/core/names.d.ts +0 -3
- package/core/options.d.ts +0 -2
- package/core/positionable_helpers.d.ts +0 -7
- package/core/procedures.d.ts +2 -25
- package/core/registry.d.ts +0 -11
- package/core/render_management.d.ts +15 -0
- package/core/rendered_connection.d.ts +22 -9
- package/core/renderers/common/block_rendering.d.ts +0 -3
- package/core/renderers/common/constants.d.ts +6 -51
- package/core/renderers/common/debug.d.ts +0 -3
- package/core/renderers/common/debugger.d.ts +9 -23
- package/core/renderers/common/drawer.d.ts +0 -5
- package/core/renderers/common/i_path_object.d.ts +0 -17
- package/core/renderers/common/info.d.ts +2 -12
- package/core/renderers/common/marker_svg.d.ts +2 -4
- package/core/renderers/common/path_object.d.ts +0 -24
- package/core/renderers/common/renderer.d.ts +5 -20
- package/core/renderers/geras/constants.d.ts +0 -5
- package/core/renderers/geras/drawer.d.ts +2 -4
- package/core/renderers/geras/highlight_constants.d.ts +6 -17
- package/core/renderers/geras/highlighter.d.ts +0 -13
- package/core/renderers/geras/info.d.ts +2 -5
- package/core/renderers/geras/measurables/inline_input.d.ts +0 -3
- package/core/renderers/geras/measurables/statement_input.d.ts +0 -3
- package/core/renderers/geras/path_object.d.ts +0 -8
- package/core/renderers/geras/renderer.d.ts +5 -7
- package/core/renderers/measurables/base.d.ts +0 -3
- package/core/renderers/measurables/bottom_row.d.ts +0 -9
- package/core/renderers/measurables/connection.d.ts +0 -3
- package/core/renderers/measurables/external_value_input.d.ts +0 -3
- package/core/renderers/measurables/field.d.ts +0 -3
- package/core/renderers/measurables/hat.d.ts +0 -3
- package/core/renderers/measurables/icon.d.ts +2 -5
- package/core/renderers/measurables/in_row_spacer.d.ts +0 -3
- package/core/renderers/measurables/inline_input.d.ts +1 -4
- package/core/renderers/measurables/input_connection.d.ts +1 -4
- package/core/renderers/measurables/input_row.d.ts +0 -7
- package/core/renderers/measurables/jagged_edge.d.ts +2 -5
- package/core/renderers/measurables/next_connection.d.ts +0 -3
- package/core/renderers/measurables/output_connection.d.ts +0 -3
- package/core/renderers/measurables/previous_connection.d.ts +0 -3
- package/core/renderers/measurables/round_corner.d.ts +0 -3
- package/core/renderers/measurables/row.d.ts +0 -39
- package/core/renderers/measurables/spacer_row.d.ts +0 -3
- package/core/renderers/measurables/square_corner.d.ts +0 -3
- package/core/renderers/measurables/statement_input.d.ts +0 -3
- package/core/renderers/measurables/top_row.d.ts +0 -6
- package/core/renderers/measurables/types.d.ts +0 -31
- package/core/renderers/minimalist/constants.d.ts +2 -4
- package/core/renderers/minimalist/drawer.d.ts +0 -3
- package/core/renderers/minimalist/info.d.ts +0 -4
- package/core/renderers/minimalist/renderer.d.ts +0 -3
- package/core/renderers/thrasos/info.d.ts +0 -4
- package/core/renderers/thrasos/renderer.d.ts +3 -3
- package/core/renderers/zelos/constants.d.ts +3 -17
- package/core/renderers/zelos/drawer.d.ts +0 -3
- package/core/renderers/zelos/info.d.ts +0 -4
- package/core/renderers/zelos/marker_svg.d.ts +0 -2
- package/core/renderers/zelos/measurables/bottom_row.d.ts +0 -3
- package/core/renderers/zelos/measurables/inputs.d.ts +0 -3
- package/core/renderers/zelos/measurables/row_elements.d.ts +0 -3
- package/core/renderers/zelos/measurables/top_row.d.ts +0 -3
- package/core/renderers/zelos/path_object.d.ts +0 -9
- package/core/renderers/zelos/renderer.d.ts +3 -5
- package/core/scrollbar.d.ts +0 -2
- package/core/scrollbar_pair.d.ts +0 -2
- package/core/serialization/blocks.d.ts +3 -9
- package/core/serialization/exceptions.d.ts +0 -8
- package/core/serialization/priorities.d.ts +0 -4
- package/core/serialization/registry.d.ts +0 -2
- package/core/serialization/variables.d.ts +0 -4
- package/core/serialization/workspaces.d.ts +0 -2
- package/core/shortcut_items.d.ts +0 -17
- package/core/shortcut_registry.d.ts +0 -2
- package/core/sprites.d.ts +0 -2
- package/core/theme/classic.d.ts +0 -2
- package/core/theme/zelos.d.ts +0 -2
- package/core/theme.d.ts +0 -2
- package/core/theme_manager.d.ts +3 -6
- package/core/toolbox/category.d.ts +5 -7
- package/core/toolbox/collapsible_category.d.ts +0 -4
- package/core/toolbox/separator.d.ts +0 -2
- package/core/toolbox/toolbox.d.ts +2 -5
- package/core/toolbox/toolbox_item.d.ts +0 -2
- package/core/tooltip.d.ts +0 -29
- package/core/touch.d.ts +0 -13
- package/core/trashcan.d.ts +0 -2
- package/core/utils/aria.d.ts +0 -6
- package/core/utils/array.d.ts +0 -1
- package/core/utils/colour.d.ts +0 -12
- package/core/utils/coordinate.d.ts +0 -2
- package/core/utils/deprecation.d.ts +0 -1
- package/core/utils/dom.d.ts +0 -25
- package/core/utils/idgenerator.d.ts +0 -2
- package/core/utils/keycodes.d.ts +0 -2
- package/core/utils/math.d.ts +0 -3
- package/core/utils/metrics.d.ts +0 -1
- package/core/utils/object.d.ts +0 -4
- package/core/utils/parsing.d.ts +0 -4
- package/core/utils/rect.d.ts +0 -2
- package/core/utils/size.d.ts +0 -2
- package/core/utils/string.d.ts +0 -6
- package/core/utils/style.d.ts +0 -8
- package/core/utils/svg.d.ts +0 -2
- package/core/utils/svg_math.d.ts +0 -6
- package/core/utils/svg_paths.d.ts +0 -8
- package/core/utils/toolbox.d.ts +2 -35
- package/core/utils/useragent.d.ts +0 -8
- package/core/utils/xml.d.ts +9 -8
- package/core/utils.d.ts +0 -12
- package/core/variable_map.d.ts +1 -3
- package/core/variable_model.d.ts +0 -1
- package/core/variables.d.ts +13 -17
- package/core/variables_dynamic.d.ts +0 -4
- package/core/warning.d.ts +0 -2
- package/core/widgetdiv.d.ts +0 -10
- package/core/workspace.d.ts +3 -3
- package/core/workspace_audio.d.ts +0 -2
- package/core/workspace_comment.d.ts +1 -3
- package/core/workspace_comment_svg.d.ts +16 -5
- package/core/workspace_drag_surface_svg.d.ts +74 -0
- package/core/workspace_dragger.d.ts +3 -2
- package/core/workspace_svg.d.ts +48 -8
- package/core/xml.d.ts +1 -13
- package/core/zoom_controls.d.ts +4 -15
- package/dart_compressed.js +199 -199
- package/dart_compressed.js.map +1 -1
- package/javascript_compressed.js +168 -168
- package/javascript_compressed.js.map +1 -1
- package/lua_compressed.js +211 -211
- package/lua_compressed.js.map +1 -1
- package/msg/bn.js +2 -2
- package/msg/bs.js +7 -7
- package/msg/de.js +1 -1
- package/msg/fi.js +1 -1
- package/msg/fr.js +3 -3
- package/msg/ia.js +5 -5
- package/msg/kn.js +5 -5
- package/msg/ko.js +1 -1
- package/msg/lb.js +22 -22
- package/msg/sd.js +9 -9
- package/msg/skr-arab.js +2 -2
- package/msg/sl.js +18 -18
- package/msg/sw.js +1 -1
- package/msg/zh-hans.js +6 -6
- package/msg/zh-hant.js +2 -2
- package/package.json +6 -6
- package/php_compressed.js +185 -185
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +138 -138
- package/python_compressed.js.map +1 -1
- package/core/utils/sentinel.d.ts +0 -18
package/lua_compressed.js
CHANGED
|
@@ -20,115 +20,142 @@ module$exports$Blockly$Lua.luaGenerator.init=function(a){Object.getPrototypeOf(t
|
|
|
20
20
|
module$exports$Blockly$Lua.luaGenerator.finish=function(a){const b=Object.values(this.definitions_);a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a};module$exports$Blockly$Lua.luaGenerator.scrubNakedValue=function(a){return"local _ = "+a+"\n"};module$exports$Blockly$Lua.luaGenerator.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"};
|
|
21
21
|
module$exports$Blockly$Lua.luaGenerator.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" .. '\\n' ..\n")};
|
|
22
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$
|
|
24
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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)
|
|
26
|
+
r = math.floor(math.min(100, math.max(0, r)) * 2.55 + .5)
|
|
27
|
+
g = math.floor(math.min(100, math.max(0, g)) * 2.55 + .5)
|
|
28
|
+
b = math.floor(math.min(100, math.max(0, b)) * 2.55 + .5)
|
|
29
|
+
return string.format("#%02x%02x%02x", r, g, b)
|
|
30
|
+
end
|
|
31
|
+
`),c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"RED",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||0,d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"GREEN",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||0;a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"BLUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
32
|
+
module$exports$Blockly$Lua.luaGenerator.colour_blend=function(a){const b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("colour_blend",`
|
|
33
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio)
|
|
34
|
+
local r1 = tonumber(string.sub(colour1, 2, 3), 16)
|
|
35
|
+
local r2 = tonumber(string.sub(colour2, 2, 3), 16)
|
|
36
|
+
local g1 = tonumber(string.sub(colour1, 4, 5), 16)
|
|
37
|
+
local g2 = tonumber(string.sub(colour2, 4, 5), 16)
|
|
38
|
+
local b1 = tonumber(string.sub(colour1, 6, 7), 16)
|
|
39
|
+
local b2 = tonumber(string.sub(colour2, 6, 7), 16)
|
|
40
|
+
local ratio = math.min(1, math.max(0, ratio))
|
|
41
|
+
local r = math.floor(r1 * (1 - ratio) + r2 * ratio + .5)
|
|
42
|
+
local g = math.floor(g1 * (1 - ratio) + g2 * ratio + .5)
|
|
43
|
+
local b = math.floor(b1 * (1 - ratio) + b2 * ratio + .5)
|
|
44
|
+
return string.format("#%02x%02x%02x", r, g, b)
|
|
45
|
+
end
|
|
46
|
+
`),c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"COLOUR1",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"'#000000'",d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"COLOUR2",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"'#000000'";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"RATIO",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};var module$exports$Blockly$Lua$lists={},module$contents$Blockly$Lua$lists_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Lua.luaGenerator.lists_create_empty=function(a){return["{}",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
47
|
+
module$exports$Blockly$Lua.luaGenerator.lists_create_with=function(a){const b=Array(a.itemCount_);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)||"None";return["{"+b.join(", ")+"}",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.lists_repeat=function(a){const b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("create_list_repeated",`
|
|
48
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(item, count)
|
|
49
|
+
local t = {}
|
|
50
|
+
for i = 1, count do
|
|
51
|
+
table.insert(t, item)
|
|
35
52
|
end
|
|
36
|
-
return
|
|
53
|
+
return t
|
|
37
54
|
end
|
|
38
|
-
`)
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
`),c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ITEM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"None";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"NUM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";return[b+"("+c+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
56
|
+
module$exports$Blockly$Lua.luaGenerator.lists_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.lists_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]};
|
|
57
|
+
module$exports$Blockly$Lua.luaGenerator.lists_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_("first_index",`
|
|
58
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
|
|
59
|
+
for k, v in ipairs(t) do
|
|
60
|
+
if v == elem then
|
|
61
|
+
return k
|
|
62
|
+
end
|
|
43
63
|
end
|
|
44
64
|
return 0
|
|
45
65
|
end
|
|
46
|
-
`)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return string.sub(str, index, index)
|
|
52
|
-
end
|
|
53
|
-
`)+"("+a+")";else{if("FIRST"===b)b="1";else if("LAST"===b)b="-1";else if("FROM_START"===b)b=c;else if("FROM_END"===b)b="-"+c;else throw Error("Unhandled option (text_charAt).");b=b.match(/^-?\w*$/)?"string.sub("+a+", "+b+", "+b+")":module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_char_at",`
|
|
54
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str, index)
|
|
55
|
-
return string.sub(str, index, index)
|
|
56
|
-
end
|
|
57
|
-
`)+"("+a+", "+b+")"}return[b,module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
58
|
-
module$exports$Blockly$Lua.luaGenerator.text_getSubstring=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"STRING",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";var c=a.getFieldValue("WHERE1"),d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT1","FROM_END"===c?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";if("FIRST"===c)c=1;else if("FROM_START"===c)c=d;else if("FROM_END"===c)c="-"+d;else throw Error("Unhandled option (text_getSubstring)");
|
|
59
|
-
d=a.getFieldValue("WHERE2");a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT2","FROM_END"===d?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";if("LAST"===d)a=-1;else if("FROM_START"!==d)if("FROM_END"===d)a="-"+a;else throw Error("Unhandled option (text_getSubstring)");return["string.sub("+b+", "+c+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
60
|
-
module$exports$Blockly$Lua.luaGenerator.text_changeCase=function(a){const b=a.getFieldValue("CASE");a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";let c;"UPPERCASE"===b?c="string.upper":"LOWERCASE"===b?c="string.lower":"TITLECASE"===b&&(c=module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_titlecase",`
|
|
61
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str)
|
|
62
|
-
local buf = {}
|
|
63
|
-
local inWord = false
|
|
64
|
-
for i = 1, #str do
|
|
65
|
-
local c = string.sub(str, i, i)
|
|
66
|
-
if inWord then
|
|
67
|
-
table.insert(buf, string.lower(c))
|
|
68
|
-
if string.find(c, "%s") then
|
|
69
|
-
inWord = false
|
|
70
|
-
end
|
|
71
|
-
else
|
|
72
|
-
table.insert(buf, string.upper(c))
|
|
73
|
-
inWord = true
|
|
66
|
+
`):module$exports$Blockly$Lua.luaGenerator.provideFunction_("last_index",`
|
|
67
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
|
|
68
|
+
for i = #t, 1, -1 do
|
|
69
|
+
if t[i] == elem then
|
|
70
|
+
return i
|
|
74
71
|
end
|
|
75
72
|
end
|
|
76
|
-
return
|
|
73
|
+
return 0
|
|
77
74
|
end
|
|
78
|
-
`))
|
|
79
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
80
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
`))+"("+c+", "+b+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};var module$contents$Blockly$Lua$lists_getListIndex=function(a,b,c){return"FIRST"===b?"1":"FROM_END"===b?"#"+a+" + 1 - "+c:"LAST"===b?"#"+a:"RANDOM"===b?"math.random(#"+a+")":c};
|
|
76
|
+
module$exports$Blockly$Lua.luaGenerator.lists_getIndex=function(a){var b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START";const d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH)||"({})";if("LAST"!==c&&"FROM_END"!==c&&"RANDOM"!==c||d.match(/^\w+$/)){a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT","GET"===b&&"FROM_END"===c?module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||
|
|
77
|
+
"1";a=module$contents$Blockly$Lua$lists_getListIndex(d,c,a);if("GET"===b)return[d+"["+a+"]",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH];c="table.remove("+d+", "+a+")";return"GET_REMOVE"===b?[c,module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]:c+"\n"}if("REMOVE"===b)return b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT","FROM_END"===c?module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1",a=module$exports$Blockly$Lua.luaGenerator.nameDB_.getDistinctName("tmp_list",
|
|
78
|
+
$.NameType$$module$build$src$core$names.VARIABLE),b=module$contents$Blockly$Lua$lists_getListIndex(a,c,b),a+" = "+d+"\ntable.remove("+a+", "+b+")\n";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";return[("GET"===b?module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_get_"+c.toLowerCase(),["function "+module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_+"(t"+("FROM_END"===c||"FROM_START"===c?", at)":")"),
|
|
79
|
+
" return t["+module$contents$Blockly$Lua$lists_getListIndex("t",c,"at")+"]","end"]):module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_remove_"+c.toLowerCase(),["function "+module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_+"(t"+("FROM_END"===c||"FROM_START"===c?", at)":")")," return table.remove(t, "+module$contents$Blockly$Lua$lists_getListIndex("t",c,"at")+")","end"]))+"("+d+("FROM_END"===c||"FROM_START"===c?", "+a:"")+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
80
|
+
module$exports$Blockly$Lua.luaGenerator.lists_setIndex=function(a){let b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH)||"{}";const c=a.getFieldValue("MODE")||"SET",d=a.getFieldValue("WHERE")||"FROM_START",e=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT",module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE)||"1";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TO",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||
|
|
81
|
+
"None";let f="";if(("LAST"===d||"FROM_END"===d||"RANDOM"===d)&&!b.match(/^\w+$/)){const g=module$exports$Blockly$Lua.luaGenerator.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE);f=g+" = "+b+"\n";b=g}f="SET"===c?f+(b+"["+module$contents$Blockly$Lua$lists_getListIndex(b,d,e)+"] = "+a):f+("table.insert("+b+", "+(module$contents$Blockly$Lua$lists_getListIndex(b,d,e)+("LAST"===d?" + 1":""))+", "+a+")");return f+"\n"};
|
|
82
|
+
module$exports$Blockly$Lua.luaGenerator.lists_getSublist=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"{}",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2"),e=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT1",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT2",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";const f="FROM_END"===
|
|
83
|
+
c||"FROM_START"===c?", at1":"",g="FROM_END"===d||"FROM_START"===d?", at2":"";return[module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_sublist_"+c.toLowerCase()+"_"+d.toLowerCase(),`
|
|
84
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(source${f}${g})
|
|
85
|
+
local t = {}
|
|
86
|
+
local start = ${module$contents$Blockly$Lua$lists_getListIndex("source",c,"at1")}
|
|
87
|
+
local finish = ${module$contents$Blockly$Lua$lists_getListIndex("source",d,"at2")}
|
|
88
|
+
for i = start, finish do
|
|
89
|
+
table.insert(t, source[i])
|
|
90
|
+
end
|
|
91
|
+
return t
|
|
85
92
|
end
|
|
86
|
-
`)+"("+b+"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
`)+"("+b+("FROM_END"===c||"FROM_START"===c?", "+e:"")+("FROM_END"===d||"FROM_START"===d?", "+a:"")+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.lists_sort=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"{}",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_sort",`
|
|
94
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(list, typev, direction)
|
|
95
|
+
local t = {}
|
|
96
|
+
for n,v in pairs(list) do table.insert(t, v) end
|
|
97
|
+
local compareFuncs = {
|
|
98
|
+
NUMERIC = function(a, b)
|
|
99
|
+
return (tonumber(tostring(a)) or 0)
|
|
100
|
+
< (tonumber(tostring(b)) or 0) end,
|
|
101
|
+
TEXT = function(a, b)
|
|
102
|
+
return tostring(a) < tostring(b) end,
|
|
103
|
+
IGNORE_CASE = function(a, b)
|
|
104
|
+
return string.lower(tostring(a)) < string.lower(tostring(b)) end
|
|
105
|
+
}
|
|
106
|
+
local compareTemp = compareFuncs[typev]
|
|
107
|
+
local compare = compareTemp
|
|
108
|
+
if direction == -1
|
|
109
|
+
then compare = function(a, b) return compareTemp(b, a) end
|
|
91
110
|
end
|
|
92
|
-
|
|
93
|
-
|
|
111
|
+
table.sort(t, compare)
|
|
112
|
+
return t
|
|
113
|
+
end
|
|
114
|
+
`)+"("+b+',"'+a+'", '+c+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
115
|
+
module$exports$Blockly$Lua.luaGenerator.lists_split=function(a){let b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"INPUT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE);const c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"DELIM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a=module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_string_split",`
|
|
116
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(input, delim)
|
|
117
|
+
local t = {}
|
|
118
|
+
local pos = 1
|
|
94
119
|
while true do
|
|
95
|
-
|
|
96
|
-
if
|
|
120
|
+
next_delim = string.find(input, delim, pos)
|
|
121
|
+
if next_delim == nil then
|
|
122
|
+
table.insert(t, string.sub(input, pos))
|
|
97
123
|
break
|
|
124
|
+
else
|
|
125
|
+
table.insert(t, string.sub(input, pos, next_delim-1))
|
|
126
|
+
pos = next_delim + #delim
|
|
98
127
|
end
|
|
99
|
-
count = count + 1
|
|
100
|
-
i = i + #needle
|
|
101
128
|
end
|
|
102
|
-
return
|
|
129
|
+
return t
|
|
103
130
|
end
|
|
104
|
-
`)+"("+b+", "+
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
local i = 1
|
|
110
|
-
while i <= #haystack do
|
|
111
|
-
if string.sub(haystack, i, i + #needle - 1) == needle then
|
|
112
|
-
for j = 1, #replacement do
|
|
113
|
-
table.insert(buf, string.sub(replacement, j, j))
|
|
114
|
-
end
|
|
115
|
-
i = i + #needle
|
|
116
|
-
else
|
|
117
|
-
table.insert(buf, string.sub(haystack, i, i))
|
|
118
|
-
i = i + 1
|
|
119
|
-
end
|
|
131
|
+
`);else if("JOIN"===a)b||(b="{}"),a="table.concat";else throw Error("Unknown mode: "+a);return[a+"("+b+", "+c+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.lists_reverse=function(a){a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"{}";return[module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_reverse",`
|
|
132
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(input)
|
|
133
|
+
local reversed = {}
|
|
134
|
+
for i = #input, 1, -1 do
|
|
135
|
+
table.insert(reversed, input[i])
|
|
120
136
|
end
|
|
121
|
-
return
|
|
137
|
+
return reversed
|
|
122
138
|
end
|
|
123
|
-
`)+"("+
|
|
124
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
129
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
130
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
131
|
-
(a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"
|
|
139
|
+
`)+"("+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};var module$exports$Blockly$Lua$logic={};
|
|
140
|
+
module$exports$Blockly$Lua.luaGenerator.controls_if=function(a){var b=0;let c="";module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX,a));do{const d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"IF"+b,module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"false";let e=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"DO"+b);module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX&&(e=
|
|
141
|
+
module$exports$Blockly$Lua.luaGenerator.prefixLines(module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Lua.luaGenerator.INDENT)+e);c+=(0<b?"else":"")+"if "+d+" then\n"+e;b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX)b=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"ELSE"),module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX&&(b=module$exports$Blockly$Lua.luaGenerator.prefixLines(module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX,
|
|
142
|
+
a),module$exports$Blockly$Lua.luaGenerator.INDENT)+b),c+="else\n"+b;return c+"end\n"};module$exports$Blockly$Lua.luaGenerator.controls_ifelse=module$exports$Blockly$Lua.luaGenerator.controls_if;
|
|
143
|
+
module$exports$Blockly$Lua.luaGenerator.logic_compare=function(a){const b={EQ:"==",NEQ:"~=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"A",module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL)||"0";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"B",module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL)||"0";return[c+" "+b+" "+a,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL]};
|
|
144
|
+
module$exports$Blockly$Lua.luaGenerator.logic_operation=function(a){const b="AND"===a.getFieldValue("OP")?"and":"or",c="and"===b?module$exports$Blockly$Lua.luaGenerator.ORDER_AND:module$exports$Blockly$Lua.luaGenerator.ORDER_OR;let d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"A",c);a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"B",c);if(d||a){const e="and"===b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};
|
|
145
|
+
module$exports$Blockly$Lua.luaGenerator.logic_negate=function(a){return["not "+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"BOOL",module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY)||"true"),module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY]};module$exports$Blockly$Lua.luaGenerator.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};
|
|
146
|
+
module$exports$Blockly$Lua.luaGenerator.logic_null=function(a){return["nil",module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};
|
|
147
|
+
module$exports$Blockly$Lua.luaGenerator.logic_ternary=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"IF",module$exports$Blockly$Lua.luaGenerator.ORDER_AND)||"false",c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"THEN",module$exports$Blockly$Lua.luaGenerator.ORDER_AND)||"nil";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ELSE",module$exports$Blockly$Lua.luaGenerator.ORDER_OR)||"nil";return[b+" and "+c+" or "+a,module$exports$Blockly$Lua.luaGenerator.ORDER_OR]};var module$exports$Blockly$Lua$loops={},module$contents$Blockly$Lua$loops_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Lua$loops_NameType=$.NameType$$module$build$src$core$names,module$contents$Blockly$Lua$loops_CONTINUE_STATEMENT="goto continue\n",module$contents$Blockly$Lua$loops_addContinueLabel=function(a){return-1!==a.indexOf(module$contents$Blockly$Lua$loops_CONTINUE_STATEMENT)?a+module$exports$Blockly$Lua.luaGenerator.INDENT+"::continue::\n":a};
|
|
148
|
+
module$exports$Blockly$Lua.luaGenerator.controls_repeat_ext=function(a){let b;b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TIMES",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";b=$.module$build$src$core$utils$string.isNumber(b)?parseInt(b,10):"math.floor("+b+")";let c=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"DO");c=module$exports$Blockly$Lua.luaGenerator.addLoopTrap(c,a);c=module$contents$Blockly$Lua$loops_addContinueLabel(c);
|
|
149
|
+
return"for "+module$exports$Blockly$Lua.luaGenerator.nameDB_.getDistinctName("count",$.NameType$$module$build$src$core$names.VARIABLE)+" = 1, "+b+" do\n"+c+"end\n"};module$exports$Blockly$Lua.luaGenerator.controls_repeat=module$exports$Blockly$Lua.luaGenerator.controls_repeat_ext;
|
|
150
|
+
module$exports$Blockly$Lua.luaGenerator.controls_whileUntil=function(a){const b="UNTIL"===a.getFieldValue("MODE");let c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"BOOL",b?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"false",d=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"DO");d=module$exports$Blockly$Lua.luaGenerator.addLoopTrap(d,a);d=module$contents$Blockly$Lua$loops_addContinueLabel(d);b&&(c="not "+c);return"while "+
|
|
151
|
+
c+" do\n"+d+"end\n"};
|
|
152
|
+
module$exports$Blockly$Lua.luaGenerator.controls_for=function(a){const b=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"FROM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0",d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TO",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0",e=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"BY",
|
|
153
|
+
module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";let f=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"DO");f=module$exports$Blockly$Lua.luaGenerator.addLoopTrap(f,a);f=module$contents$Blockly$Lua$loops_addContinueLabel(f);a="";let g;$.module$build$src$core$utils$string.isNumber(c)&&$.module$build$src$core$utils$string.isNumber(d)&&$.module$build$src$core$utils$string.isNumber(e)?g=(Number(c)<=Number(d)?"":"-")+Math.abs(Number(e)):(a="",g=module$exports$Blockly$Lua.luaGenerator.nameDB_.getDistinctName(b+
|
|
154
|
+
"_inc",$.NameType$$module$build$src$core$names.VARIABLE),a+=g+" = ",a=$.module$build$src$core$utils$string.isNumber(e)?a+(Math.abs(e)+"\n"):a+("math.abs("+e+")\n"),a=a+("if ("+c+") > ("+d+") then\n")+(module$exports$Blockly$Lua.luaGenerator.INDENT+g+" = -"+g+"\n"),a+="end\n");return a+("for "+b+" = "+c+", "+d+", "+g)+(" do\n"+f+"end\n")};
|
|
155
|
+
module$exports$Blockly$Lua.luaGenerator.controls_forEach=function(a){const b=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"{}";let d=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"DO");d=module$exports$Blockly$Lua.luaGenerator.addLoopTrap(d,a);d=module$contents$Blockly$Lua$loops_addContinueLabel(d);
|
|
156
|
+
return"for _, "+b+" in ipairs("+c+") do \n"+d+"end\n"};
|
|
157
|
+
module$exports$Blockly$Lua.luaGenerator.controls_flow_statements=function(a){let b="";module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX&&(b+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX,a));if(module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX){const c=a.getSurroundLoop();
|
|
158
|
+
c&&!c.suppressPrefixSuffix&&(b+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break\n";case "CONTINUE":return b+module$contents$Blockly$Lua$loops_CONTINUE_STATEMENT}throw Error("Unknown flow statement.");};var module$exports$Blockly$Lua$math={},module$contents$Blockly$Lua$math_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Lua.luaGenerator.math_number=function(a){a=Number(a.getFieldValue("NUM"));return[a,0>a?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};
|
|
132
159
|
module$exports$Blockly$Lua.luaGenerator.math_arithmetic=function(a){var b={ADD:[" + ",module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE],MINUS:[" - ",module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE],MULTIPLY:[" * ",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE],POWER:[" ^ ",module$exports$Blockly$Lua.luaGenerator.ORDER_EXPONENTIATION]}[a.getFieldValue("OP")];const c=b[0];b=b[1];const d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,
|
|
133
160
|
"A",b)||"0";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
|
|
134
161
|
module$exports$Blockly$Lua.luaGenerator.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"===b)return a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"NUM",module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY)||"0",["-"+a,module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY];if("POW10"===b)return a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"NUM",module$exports$Blockly$Lua.luaGenerator.ORDER_EXPONENTIATION)||"0",["10 ^ "+a,module$exports$Blockly$Lua.luaGenerator.ORDER_EXPONENTIATION];
|
|
@@ -271,142 +298,115 @@ end
|
|
|
271
298
|
`);break;default:throw Error("Unknown operator: "+c);}return[c+"("+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.math_modulo=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"DIVIDEND",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE)||"0";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE]};
|
|
272
299
|
module$exports$Blockly$Lua.luaGenerator.math_constrain=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0",c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LOW",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"-math.huge";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"HIGH",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"math.huge";return["math.min(math.max("+b+", "+c+"), "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
273
300
|
module$exports$Blockly$Lua.luaGenerator.math_random_int=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"FROM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TO",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";return["math.random("+b+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.math_random_float=function(a){return["math.random()",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
274
|
-
module$exports$Blockly$Lua.luaGenerator.math_atan2=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"X",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";return["math.deg(math.atan2("+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"Y",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0")+", "+b+"))",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};var module$exports$Blockly$Lua$
|
|
275
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
276
|
-
|
|
277
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
278
|
-
|
|
279
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
280
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
281
|
-
|
|
282
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
283
|
-
|
|
284
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
285
|
-
|
|
286
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
287
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
288
|
-
a),module$exports$Blockly$Lua.luaGenerator.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
module$exports$Blockly$Lua.luaGenerator.logic_ternary=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"IF",module$exports$Blockly$Lua.luaGenerator.ORDER_AND)||"false",c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"THEN",module$exports$Blockly$Lua.luaGenerator.ORDER_AND)||"nil";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ELSE",module$exports$Blockly$Lua.luaGenerator.ORDER_OR)||"nil";return[b+" and "+c+" or "+a,module$exports$Blockly$Lua.luaGenerator.ORDER_OR]};var module$exports$Blockly$Lua$lists={},module$contents$Blockly$Lua$lists_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Lua.luaGenerator.lists_create_empty=function(a){return["{}",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
294
|
-
module$exports$Blockly$Lua.luaGenerator.lists_create_with=function(a){const b=Array(a.itemCount_);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)||"None";return["{"+b.join(", ")+"}",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.lists_repeat=function(a){const b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("create_list_repeated",`
|
|
295
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(item, count)
|
|
296
|
-
local t = {}
|
|
297
|
-
for i = 1, count do
|
|
298
|
-
table.insert(t, item)
|
|
301
|
+
module$exports$Blockly$Lua.luaGenerator.math_atan2=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"X",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";return["math.deg(math.atan2("+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"Y",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0")+", "+b+"))",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};var module$exports$Blockly$Lua$procedures={},module$contents$Blockly$Lua$procedures_NameType=$.NameType$$module$build$src$core$names;
|
|
302
|
+
module$exports$Blockly$Lua.luaGenerator.procedures_defreturn=function(a){const b=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);var c="";module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX&&(c+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX,
|
|
303
|
+
a));c&&(c=module$exports$Blockly$Lua.luaGenerator.prefixLines(c,module$exports$Blockly$Lua.luaGenerator.INDENT));let d="";module$exports$Blockly$Lua.luaGenerator.INFINITE_LOOP_TRAP&&(d=module$exports$Blockly$Lua.luaGenerator.prefixLines(module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.INFINITE_LOOP_TRAP,a),module$exports$Blockly$Lua.luaGenerator.INDENT));let e=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"STACK"),f=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,
|
|
304
|
+
"RETURN",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"",g="";e&&f&&(g=c);f?f=module$exports$Blockly$Lua.luaGenerator.INDENT+"return "+f+"\n":e||(e="");const h=[],k=a.getVars();for(let l=0;l<k.length;l++)h[l]=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(k[l],$.NameType$$module$build$src$core$names.VARIABLE);c="function "+b+"("+h.join(", ")+")\n"+c+d+e+g+f+"end\n";c=module$exports$Blockly$Lua.luaGenerator.scrub_(a,c);module$exports$Blockly$Lua.luaGenerator.definitions_["%"+b]=c;
|
|
305
|
+
return null};module$exports$Blockly$Lua.luaGenerator.procedures_defnoreturn=module$exports$Blockly$Lua.luaGenerator.procedures_defreturn;
|
|
306
|
+
module$exports$Blockly$Lua.luaGenerator.procedures_callreturn=function(a){const b=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),c=[],d=a.getVars();for(let e=0;e<d.length;e++)c[e]=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ARG"+e,module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"nil";return[b+"("+c.join(", ")+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
307
|
+
module$exports$Blockly$Lua.luaGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$Lua.luaGenerator.procedures_callreturn(a)[0]+"\n"};
|
|
308
|
+
module$exports$Blockly$Lua.luaGenerator.procedures_ifreturn=function(a){let b="if "+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"CONDITION",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"false")+" then\n";module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$Lua.luaGenerator.prefixLines(module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Lua.luaGenerator.INDENT));a.hasReturnValue_?
|
|
309
|
+
(a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"nil",b+=module$exports$Blockly$Lua.luaGenerator.INDENT+"return "+a+"\n"):b+=module$exports$Blockly$Lua.luaGenerator.INDENT+"return\n";return b+"end\n"};var module$exports$Blockly$Lua$texts={},module$contents$Blockly$Lua$texts_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Lua.luaGenerator.text=function(a){return[module$exports$Blockly$Lua.luaGenerator.quote_(a.getFieldValue("TEXT")),module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};
|
|
310
|
+
module$exports$Blockly$Lua.luaGenerator.text_multiline=function(a){a=module$exports$Blockly$Lua.luaGenerator.multiline_quote_(a.getFieldValue("TEXT"));const b=-1!==a.indexOf("..")?module$exports$Blockly$Lua.luaGenerator.ORDER_CONCATENATION:module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC;return[a,b]};
|
|
311
|
+
module$exports$Blockly$Lua.luaGenerator.text_join=function(a){if(0===a.itemCount_)return["''",module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC];if(1===a.itemCount_)return["tostring("+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ADD0",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH];if(2===a.itemCount_){var b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ADD0",module$exports$Blockly$Lua.luaGenerator.ORDER_CONCATENATION)||
|
|
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)
|
|
317
|
+
local i = string.find(str, substr, 1, true)
|
|
318
|
+
if i == nil then
|
|
319
|
+
return 0
|
|
299
320
|
end
|
|
300
|
-
return
|
|
321
|
+
return i
|
|
301
322
|
end
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if v == elem then
|
|
308
|
-
return k
|
|
309
|
-
end
|
|
323
|
+
`):module$exports$Blockly$Lua.luaGenerator.provideFunction_("lastIndexOf",`
|
|
324
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
|
|
325
|
+
local i = string.find(string.reverse(str), string.reverse(substr), 1, true)
|
|
326
|
+
if i then
|
|
327
|
+
return #str + 2 - i - #substr
|
|
310
328
|
end
|
|
311
329
|
return 0
|
|
312
330
|
end
|
|
313
|
-
`)
|
|
314
|
-
function $
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
331
|
+
`))+"("+c+", "+b+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
332
|
+
module$exports$Blockly$Lua.luaGenerator.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START";const c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT","FROM_END"===b?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";if("RANDOM"===b)b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_random_letter",
|
|
333
|
+
`
|
|
334
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str)
|
|
335
|
+
local index = math.random(string.len(str))
|
|
336
|
+
return string.sub(str, index, index)
|
|
337
|
+
end
|
|
338
|
+
`)+"("+a+")";else{if("FIRST"===b)b="1";else if("LAST"===b)b="-1";else if("FROM_START"===b)b=c;else if("FROM_END"===b)b="-"+c;else throw Error("Unhandled option (text_charAt).");b=b.match(/^-?\w*$/)?"string.sub("+a+", "+b+", "+b+")":module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_char_at",`
|
|
339
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str, index)
|
|
340
|
+
return string.sub(str, index, index)
|
|
341
|
+
end
|
|
342
|
+
`)+"("+a+", "+b+")"}return[b,module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
343
|
+
module$exports$Blockly$Lua.luaGenerator.text_getSubstring=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"STRING",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";var c=a.getFieldValue("WHERE1"),d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT1","FROM_END"===c?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";if("FIRST"===c)c=1;else if("FROM_START"===c)c=d;else if("FROM_END"===c)c="-"+d;else throw Error("Unhandled option (text_getSubstring)");
|
|
344
|
+
d=a.getFieldValue("WHERE2");a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT2","FROM_END"===d?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";if("LAST"===d)a=-1;else if("FROM_START"!==d)if("FROM_END"===d)a="-"+a;else throw Error("Unhandled option (text_getSubstring)");return["string.sub("+b+", "+c+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
345
|
+
module$exports$Blockly$Lua.luaGenerator.text_changeCase=function(a){const b=a.getFieldValue("CASE");a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";let c;"UPPERCASE"===b?c="string.upper":"LOWERCASE"===b?c="string.lower":"TITLECASE"===b&&(c=module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_titlecase",`
|
|
346
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str)
|
|
347
|
+
local buf = {}
|
|
348
|
+
local inWord = false
|
|
349
|
+
for i = 1, #str do
|
|
350
|
+
local c = string.sub(str, i, i)
|
|
351
|
+
if inWord then
|
|
352
|
+
table.insert(buf, string.lower(c))
|
|
353
|
+
if string.find(c, "%s") then
|
|
354
|
+
inWord = false
|
|
355
|
+
end
|
|
356
|
+
else
|
|
357
|
+
table.insert(buf, string.upper(c))
|
|
358
|
+
inWord = true
|
|
318
359
|
end
|
|
319
360
|
end
|
|
320
|
-
return
|
|
361
|
+
return table.concat(buf)
|
|
321
362
|
end
|
|
322
|
-
`))+"("+
|
|
323
|
-
module$exports$Blockly$Lua.luaGenerator.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
module$exports$Blockly$Lua.luaGenerator.lists_getSublist=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"{}",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2"),e=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT1",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT2",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";const f="FROM_END"===
|
|
330
|
-
c||"FROM_START"===c?", at1":"",g="FROM_END"===d||"FROM_START"===d?", at2":"";return[module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_sublist_"+c.toLowerCase()+"_"+d.toLowerCase(),`
|
|
331
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(source${f}${g})
|
|
332
|
-
local t = {}
|
|
333
|
-
local start = ${module$contents$Blockly$Lua$lists_getListIndex("source",c,"at1")}
|
|
334
|
-
local finish = ${module$contents$Blockly$Lua$lists_getListIndex("source",d,"at2")}
|
|
335
|
-
for i = start, finish do
|
|
336
|
-
table.insert(t, source[i])
|
|
337
|
-
end
|
|
338
|
-
return t
|
|
363
|
+
`));return[c+"("+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.text_trim=function(a){const b={LEFT:"^%s*(,-)",RIGHT:"(.-)%s*$",BOTH:"^%s*(.-)%s*$"}[a.getFieldValue("MODE")];return["string.gsub("+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''")+', "'+b+'", "%1")',module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
364
|
+
module$exports$Blockly$Lua.luaGenerator.text_print=function(a){return"print("+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''")+")\n"};
|
|
365
|
+
module$exports$Blockly$Lua.luaGenerator.text_prompt_ext=function(a){var b=a.getField("TEXT")?module$exports$Blockly$Lua.luaGenerator.quote_(a.getFieldValue("TEXT")):module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_prompt",`
|
|
366
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(msg)
|
|
367
|
+
io.write(msg)
|
|
368
|
+
io.flush()
|
|
369
|
+
return io.read()
|
|
339
370
|
end
|
|
340
|
-
`)+"("+b+
|
|
341
|
-
function $
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
NUMERIC = function(a, b)
|
|
346
|
-
return (tonumber(tostring(a)) or 0)
|
|
347
|
-
< (tonumber(tostring(b)) or 0) end,
|
|
348
|
-
TEXT = function(a, b)
|
|
349
|
-
return tostring(a) < tostring(b) end,
|
|
350
|
-
IGNORE_CASE = function(a, b)
|
|
351
|
-
return string.lower(tostring(a)) < string.lower(tostring(b)) end
|
|
352
|
-
}
|
|
353
|
-
local compareTemp = compareFuncs[typev]
|
|
354
|
-
local compare = compareTemp
|
|
355
|
-
if direction == -1
|
|
356
|
-
then compare = function(a, b) return compareTemp(b, a) end
|
|
371
|
+
`)+"("+b+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="tonumber("+b+", 10)");return[b,module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.text_prompt=module$exports$Blockly$Lua.luaGenerator.text_prompt_ext;
|
|
372
|
+
module$exports$Blockly$Lua.luaGenerator.text_count=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"SUB",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";return[module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_count",`
|
|
373
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle)
|
|
374
|
+
if #needle == 0 then
|
|
375
|
+
return #haystack + 1
|
|
357
376
|
end
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
end
|
|
361
|
-
`)+"("+b+',"'+a+'", '+c+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
362
|
-
module$exports$Blockly$Lua.luaGenerator.lists_split=function(a){let b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"INPUT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE);const c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"DELIM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a=module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_string_split",`
|
|
363
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(input, delim)
|
|
364
|
-
local t = {}
|
|
365
|
-
local pos = 1
|
|
377
|
+
local i = 1
|
|
378
|
+
local count = 0
|
|
366
379
|
while true do
|
|
367
|
-
|
|
368
|
-
if
|
|
369
|
-
table.insert(t, string.sub(input, pos))
|
|
380
|
+
i = string.find(haystack, needle, i, true)
|
|
381
|
+
if i == nil then
|
|
370
382
|
break
|
|
371
|
-
else
|
|
372
|
-
table.insert(t, string.sub(input, pos, next_delim-1))
|
|
373
|
-
pos = next_delim + #delim
|
|
374
383
|
end
|
|
384
|
+
count = count + 1
|
|
385
|
+
i = i + #needle
|
|
375
386
|
end
|
|
376
|
-
return
|
|
387
|
+
return count
|
|
377
388
|
end
|
|
378
|
-
`)
|
|
379
|
-
function $
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
389
|
+
`)+"("+b+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
390
|
+
module$exports$Blockly$Lua.luaGenerator.text_replace=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''",c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"FROM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TO",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";return[module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_replace",
|
|
391
|
+
`
|
|
392
|
+
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement)
|
|
393
|
+
local buf = {}
|
|
394
|
+
local i = 1
|
|
395
|
+
while i <= #haystack do
|
|
396
|
+
if string.sub(haystack, i, i + #needle - 1) == needle then
|
|
397
|
+
for j = 1, #replacement do
|
|
398
|
+
table.insert(buf, string.sub(replacement, j, j))
|
|
399
|
+
end
|
|
400
|
+
i = i + #needle
|
|
401
|
+
else
|
|
402
|
+
table.insert(buf, string.sub(haystack, i, i))
|
|
403
|
+
i = i + 1
|
|
404
|
+
end
|
|
383
405
|
end
|
|
384
|
-
return
|
|
385
|
-
end
|
|
386
|
-
`)+"("+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};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]};
|
|
387
|
-
module$exports$Blockly$Lua.luaGenerator.colour_rgb=function(a){const b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("colour_rgb",`
|
|
388
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b)
|
|
389
|
-
r = math.floor(math.min(100, math.max(0, r)) * 2.55 + .5)
|
|
390
|
-
g = math.floor(math.min(100, math.max(0, g)) * 2.55 + .5)
|
|
391
|
-
b = math.floor(math.min(100, math.max(0, b)) * 2.55 + .5)
|
|
392
|
-
return string.format("#%02x%02x%02x", r, g, b)
|
|
393
|
-
end
|
|
394
|
-
`),c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"RED",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||0,d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"GREEN",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||0;a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"BLUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
|
395
|
-
module$exports$Blockly$Lua.luaGenerator.colour_blend=function(a){const b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("colour_blend",`
|
|
396
|
-
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio)
|
|
397
|
-
local r1 = tonumber(string.sub(colour1, 2, 3), 16)
|
|
398
|
-
local r2 = tonumber(string.sub(colour2, 2, 3), 16)
|
|
399
|
-
local g1 = tonumber(string.sub(colour1, 4, 5), 16)
|
|
400
|
-
local g2 = tonumber(string.sub(colour2, 4, 5), 16)
|
|
401
|
-
local b1 = tonumber(string.sub(colour1, 6, 7), 16)
|
|
402
|
-
local b2 = tonumber(string.sub(colour2, 6, 7), 16)
|
|
403
|
-
local ratio = math.min(1, math.max(0, ratio))
|
|
404
|
-
local r = math.floor(r1 * (1 - ratio) + r2 * ratio + .5)
|
|
405
|
-
local g = math.floor(g1 * (1 - ratio) + g2 * ratio + .5)
|
|
406
|
-
local b = math.floor(b1 * (1 - ratio) + b2 * ratio + .5)
|
|
407
|
-
return string.format("#%02x%02x%02x", r, g, b)
|
|
406
|
+
return table.concat(buf)
|
|
408
407
|
end
|
|
409
|
-
`),c
|
|
408
|
+
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.text_reverse=function(a){return["string.reverse("+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};var module$exports$Blockly$Lua$variables={},module$contents$Blockly$Lua$variables_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Lua.luaGenerator.variables_get=function(a){return[module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};
|
|
409
|
+
module$exports$Blockly$Lua.luaGenerator.variables_set=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";return module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+b+"\n"};var module$exports$Blockly$Lua$variablesDynamic={};module$exports$Blockly$Lua.luaGenerator.variables_get_dynamic=module$exports$Blockly$Lua.luaGenerator.variables_get;module$exports$Blockly$Lua.luaGenerator.variables_set_dynamic=module$exports$Blockly$Lua.luaGenerator.variables_set;var module$exports$Blockly$Lua$all=module$exports$Blockly$Lua;
|
|
410
410
|
module$exports$Blockly$Lua.__namespace__=$;
|
|
411
411
|
return module$exports$Blockly$Lua;
|
|
412
412
|
}));
|