scratch-blocks 2.0.2 → 2.0.4
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/.nvmrc +1 -1
- package/commitlint.config.js +2 -2
- package/dist/main.mjs +1 -2
- package/dist/types/msg/scratch_msgs.d.ts.map +1 -1
- package/dist/types/src/block_reporting.d.ts.map +1 -1
- package/dist/types/src/blocks/colour.d.ts +0 -19
- package/dist/types/src/blocks/colour.d.ts.map +1 -1
- package/dist/types/src/blocks/control.d.ts +0 -19
- package/dist/types/src/blocks/control.d.ts.map +1 -1
- package/dist/types/src/blocks/data.d.ts +0 -19
- package/dist/types/src/blocks/data.d.ts.map +1 -1
- package/dist/types/src/blocks/event.d.ts +0 -19
- package/dist/types/src/blocks/event.d.ts.map +1 -1
- package/dist/types/src/blocks/looks.d.ts +0 -19
- package/dist/types/src/blocks/looks.d.ts.map +1 -1
- package/dist/types/src/blocks/math.d.ts +0 -19
- package/dist/types/src/blocks/math.d.ts.map +1 -1
- package/dist/types/src/blocks/matrix.d.ts +0 -19
- package/dist/types/src/blocks/matrix.d.ts.map +1 -1
- package/dist/types/src/blocks/motion.d.ts +0 -19
- package/dist/types/src/blocks/motion.d.ts.map +1 -1
- package/dist/types/src/blocks/note.d.ts +0 -19
- package/dist/types/src/blocks/note.d.ts.map +1 -1
- package/dist/types/src/blocks/operators.d.ts +0 -19
- package/dist/types/src/blocks/operators.d.ts.map +1 -1
- package/dist/types/src/blocks/procedures.d.ts +7 -10
- package/dist/types/src/blocks/procedures.d.ts.map +1 -1
- package/dist/types/src/blocks/sensing.d.ts +0 -19
- package/dist/types/src/blocks/sensing.d.ts.map +1 -1
- package/dist/types/src/blocks/sound.d.ts +0 -19
- package/dist/types/src/blocks/sound.d.ts.map +1 -1
- package/dist/types/src/blocks/text.d.ts +0 -19
- package/dist/types/src/blocks/text.d.ts.map +1 -1
- package/dist/types/src/blocks/vertical_extensions.d.ts +0 -19
- package/dist/types/src/blocks/vertical_extensions.d.ts.map +1 -1
- package/dist/types/src/checkable_continuous_flyout.d.ts +2 -7
- package/dist/types/src/checkable_continuous_flyout.d.ts.map +1 -1
- package/dist/types/src/checkbox_bubble.d.ts +13 -12
- package/dist/types/src/checkbox_bubble.d.ts.map +1 -1
- package/dist/types/src/colours.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +0 -7
- package/dist/types/src/constants.d.ts.map +1 -1
- package/dist/types/src/context_menu_items.d.ts +0 -5
- package/dist/types/src/context_menu_items.d.ts.map +1 -1
- package/dist/types/src/data_category.d.ts +2 -4
- package/dist/types/src/data_category.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_base.d.ts +2 -3
- package/dist/types/src/events/events_block_comment_base.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_change.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_change.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_collapse.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_collapse.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_create.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_create.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_delete.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_delete.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_move.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_move.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_resize.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_resize.d.ts.map +1 -1
- package/dist/types/src/events/events_block_drag_end.d.ts +1 -2
- package/dist/types/src/events/events_block_drag_end.d.ts.map +1 -1
- package/dist/types/src/events/events_block_drag_outside.d.ts +1 -2
- package/dist/types/src/events/events_block_drag_outside.d.ts.map +1 -1
- package/dist/types/src/events/events_scratch_variable_create.d.ts +0 -5
- package/dist/types/src/events/events_scratch_variable_create.d.ts.map +1 -1
- package/dist/types/src/fields/field_colour_slider.d.ts +7 -9
- package/dist/types/src/fields/field_colour_slider.d.ts.map +1 -1
- package/dist/types/src/fields/field_matrix.d.ts +0 -19
- package/dist/types/src/fields/field_matrix.d.ts.map +1 -1
- package/dist/types/src/fields/field_note.d.ts +8 -23
- package/dist/types/src/fields/field_note.d.ts.map +1 -1
- package/dist/types/src/fields/field_textinput_removable.d.ts +2 -4
- package/dist/types/src/fields/field_textinput_removable.d.ts.map +1 -1
- package/dist/types/src/fields/field_variable_getter.d.ts +0 -19
- package/dist/types/src/fields/field_variable_getter.d.ts.map +1 -1
- package/dist/types/src/fields/field_vertical_separator.d.ts +0 -19
- package/dist/types/src/fields/field_vertical_separator.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_angle.d.ts +0 -19
- package/dist/types/src/fields/scratch_field_angle.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_dropdown.d.ts +0 -5
- package/dist/types/src/fields/scratch_field_dropdown.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_number.d.ts +0 -19
- package/dist/types/src/fields/scratch_field_number.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_variable.d.ts +4 -7
- package/dist/types/src/fields/scratch_field_variable.d.ts.map +1 -1
- package/dist/types/src/flyout_checkbox_icon.d.ts +2 -3
- package/dist/types/src/flyout_checkbox_icon.d.ts.map +1 -1
- package/dist/types/src/glows.d.ts +1 -3
- package/dist/types/src/glows.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +50 -55
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/procedures.d.ts +6 -8
- package/dist/types/src/procedures.d.ts.map +1 -1
- package/dist/types/src/recyclable_block_flyout_inflater.d.ts +3 -5
- package/dist/types/src/recyclable_block_flyout_inflater.d.ts.map +1 -1
- package/dist/types/src/renderer/bowler_hat.d.ts +2 -3
- package/dist/types/src/renderer/bowler_hat.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/cat_face.d.ts +6 -5
- package/dist/types/src/renderer/cat/cat_face.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/constants.d.ts +2 -2
- package/dist/types/src/renderer/cat/constants.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/drawer.d.ts +3 -4
- package/dist/types/src/renderer/cat/drawer.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/path_object.d.ts +2 -3
- package/dist/types/src/renderer/cat/path_object.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/render_info.d.ts +3 -4
- package/dist/types/src/renderer/cat/render_info.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/renderer.d.ts +6 -7
- package/dist/types/src/renderer/cat/renderer.d.ts.map +1 -1
- package/dist/types/src/renderer/constants.d.ts +4 -4
- package/dist/types/src/renderer/constants.d.ts.map +1 -1
- package/dist/types/src/renderer/drawer.d.ts +5 -4
- package/dist/types/src/renderer/drawer.d.ts.map +1 -1
- package/dist/types/src/renderer/path_object.d.ts +1 -3
- package/dist/types/src/renderer/path_object.d.ts.map +1 -1
- package/dist/types/src/renderer/render_info.d.ts +3 -4
- package/dist/types/src/renderer/render_info.d.ts.map +1 -1
- package/dist/types/src/renderer/renderer.d.ts +8 -15
- package/dist/types/src/renderer/renderer.d.ts.map +1 -1
- package/dist/types/src/scratch_block_paster.d.ts +0 -5
- package/dist/types/src/scratch_block_paster.d.ts.map +1 -1
- package/dist/types/src/scratch_blocks_utils.d.ts +0 -20
- package/dist/types/src/scratch_blocks_utils.d.ts.map +1 -1
- package/dist/types/src/scratch_comment_bubble.d.ts +1 -4
- package/dist/types/src/scratch_comment_bubble.d.ts.map +1 -1
- package/dist/types/src/scratch_comment_icon.d.ts +2 -3
- package/dist/types/src/scratch_comment_icon.d.ts.map +1 -1
- package/dist/types/src/scratch_connection_checker.d.ts +0 -5
- package/dist/types/src/scratch_connection_checker.d.ts.map +1 -1
- package/dist/types/src/scratch_continuous_category.d.ts +5 -5
- package/dist/types/src/scratch_continuous_category.d.ts.map +1 -1
- package/dist/types/src/scratch_continuous_toolbox.d.ts +3 -6
- package/dist/types/src/scratch_continuous_toolbox.d.ts.map +1 -1
- package/dist/types/src/scratch_dragger.d.ts +3 -12
- package/dist/types/src/scratch_dragger.d.ts.map +1 -1
- package/dist/types/src/scratch_insertion_marker_previewer.d.ts +0 -5
- package/dist/types/src/scratch_insertion_marker_previewer.d.ts.map +1 -1
- package/dist/types/src/scratch_variable_map.d.ts +0 -5
- package/dist/types/src/scratch_variable_map.d.ts.map +1 -1
- package/dist/types/src/scratch_variable_model.d.ts +1 -2
- package/dist/types/src/scratch_variable_model.d.ts.map +1 -1
- package/dist/types/src/scratch_zoom_controls.d.ts +4 -6
- package/dist/types/src/scratch_zoom_controls.d.ts.map +1 -1
- package/dist/types/src/shadows.d.ts +2 -2
- package/dist/types/src/shadows.d.ts.map +1 -1
- package/dist/types/src/status_indicator_label.d.ts +4 -6
- package/dist/types/src/status_indicator_label.d.ts.map +1 -1
- package/dist/types/src/status_indicator_label_flyout_inflater.d.ts +1 -6
- package/dist/types/src/status_indicator_label_flyout_inflater.d.ts.map +1 -1
- package/dist/types/src/variables.d.ts +4 -8
- package/dist/types/src/variables.d.ts.map +1 -1
- package/dist/types/src/xml.d.ts +2 -3
- package/dist/types/src/xml.d.ts.map +1 -1
- package/dist/types/tests/jsunit/block_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/connection_db_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/connection_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/event_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/extensions_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_number_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_variable_getter_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_variable_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/gesture_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/input_test.d.ts +1 -0
- package/dist/types/tests/jsunit/input_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/json_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/names_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/procedure_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/scratch_block_comment_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/svg_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/test_utilities.d.ts.map +1 -1
- package/dist/types/tests/jsunit/utils_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/variable_map_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/variable_model_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/widget_div_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_comment_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_undo_redo_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/xml_test.d.ts.map +1 -1
- package/dist/types/tests/workspace_svg/workspace_svg_test.d.ts.map +1 -1
- package/eslint.config.mjs +69 -0
- package/i18n/create_scratch_msgs.js +44 -45
- package/i18n/js_to_json.js +40 -32
- package/i18n/json_to_js.js +37 -37
- package/i18n/sync_tx_translations.js +64 -65
- package/i18n/test_scratch_msgs.js +66 -63
- package/msg/js/en.js +289 -287
- package/msg/json/en.json +284 -284
- package/msg/messages.js +289 -287
- package/msg/scratch_msgs.js +22959 -22970
- package/package.json +13 -10
- package/prettier.config.mjs +3 -0
- package/release.config.js +7 -7
- package/renovate.json5 +7 -9
- package/src/block_reporting.ts +15 -18
- package/src/blocks/colour.ts +12 -15
- package/src/blocks/control.ts +167 -177
- package/src/blocks/data.ts +225 -292
- package/src/blocks/event.ts +121 -123
- package/src/blocks/looks.ts +165 -167
- package/src/blocks/math.ts +44 -46
- package/src/blocks/matrix.ts +11 -13
- package/src/blocks/motion.ts +151 -153
- package/src/blocks/note.ts +11 -13
- package/src/blocks/operators.ts +158 -160
- package/src/blocks/procedures.ts +488 -536
- package/src/blocks/sensing.ts +163 -165
- package/src/blocks/sound.ts +58 -60
- package/src/blocks/text.ts +10 -12
- package/src/blocks/vertical_extensions.ts +86 -102
- package/src/checkable_continuous_flyout.ts +25 -42
- package/src/checkbox_bubble.ts +83 -100
- package/src/colours.ts +35 -37
- package/src/constants.ts +22 -29
- package/src/context_menu_items.ts +56 -81
- package/src/css.ts +3 -4
- package/src/data_category.ts +136 -250
- package/src/events/events_block_comment_base.ts +21 -31
- package/src/events/events_block_comment_change.ts +21 -42
- package/src/events/events_block_comment_collapse.ts +22 -43
- package/src/events/events_block_comment_create.ts +29 -46
- package/src/events/events_block_comment_delete.ts +10 -19
- package/src/events/events_block_comment_move.ts +27 -52
- package/src/events/events_block_comment_resize.ts +28 -55
- package/src/events/events_block_drag_end.ts +16 -26
- package/src/events/events_block_drag_outside.ts +12 -22
- package/src/events/events_scratch_variable_create.ts +33 -56
- package/src/fields/field_colour_slider.ts +173 -228
- package/src/fields/field_matrix.ts +200 -269
- package/src/fields/field_note.ts +272 -377
- package/src/fields/field_textinput_removable.ts +25 -40
- package/src/fields/field_variable_getter.ts +26 -31
- package/src/fields/field_vertical_separator.ts +19 -24
- package/src/fields/scratch_field_angle.ts +150 -186
- package/src/fields/scratch_field_dropdown.ts +15 -19
- package/src/fields/scratch_field_number.ts +123 -180
- package/src/fields/scratch_field_variable.ts +52 -73
- package/src/flyout_checkbox_icon.ts +18 -28
- package/src/glows.ts +51 -58
- package/src/index.ts +119 -133
- package/src/procedures.ts +144 -211
- package/src/recyclable_block_flyout_inflater.ts +14 -25
- package/src/renderer/bowler_hat.ts +6 -8
- package/src/renderer/cat/cat_face.ts +98 -99
- package/src/renderer/cat/constants.ts +67 -87
- package/src/renderer/cat/drawer.ts +21 -27
- package/src/renderer/cat/path_object.ts +3 -5
- package/src/renderer/cat/render_info.ts +5 -8
- package/src/renderer/cat/renderer.ts +11 -15
- package/src/renderer/constants.ts +34 -49
- package/src/renderer/drawer.ts +35 -51
- package/src/renderer/path_object.ts +13 -15
- package/src/renderer/render_info.ts +36 -56
- package/src/renderer/renderer.ts +16 -29
- package/src/scratch_block_paster.ts +12 -20
- package/src/scratch_blocks_utils.ts +4 -7
- package/src/scratch_comment_bubble.ts +70 -101
- package/src/scratch_comment_icon.ts +74 -123
- package/src/scratch_connection_checker.ts +22 -17
- package/src/scratch_continuous_category.ts +24 -28
- package/src/scratch_continuous_toolbox.ts +20 -27
- package/src/scratch_dragger.ts +54 -86
- package/src/scratch_insertion_marker_previewer.ts +6 -11
- package/src/scratch_variable_map.ts +5 -12
- package/src/scratch_variable_model.ts +4 -11
- package/src/scratch_zoom_controls.ts +101 -156
- package/src/shadows.ts +32 -37
- package/src/status_indicator_label.ts +54 -67
- package/src/status_indicator_label_flyout_inflater.ts +11 -21
- package/src/variables.ts +89 -138
- package/src/xml.ts +21 -35
- package/tsconfig.json +2 -6
- package/types/continuous-toolbox.d.ts +1 -1
- package/dist/main.mjs.LICENSE.txt +0 -163
package/src/blocks/control.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license
|
|
3
2
|
* Visual Blocks Editor
|
|
4
3
|
*
|
|
5
4
|
* Copyright 2016 Massachusetts Institute of Technology
|
|
@@ -17,208 +16,199 @@
|
|
|
17
16
|
* See the License for the specific language governing permissions and
|
|
18
17
|
* limitations under the License.
|
|
19
18
|
*/
|
|
19
|
+
import * as Blockly from 'blockly/core'
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Blockly.Blocks["control_forever"] = {
|
|
21
|
+
Blockly.Blocks.control_forever = {
|
|
24
22
|
/**
|
|
25
23
|
* Block for repeat n times (external number).
|
|
26
24
|
* https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#5eke39
|
|
27
25
|
*/
|
|
28
26
|
init: function (this: Blockly.Block) {
|
|
29
|
-
const ws = this.workspace.options.parentWorkspace || this.workspace
|
|
27
|
+
const ws = this.workspace.options.parentWorkspace || this.workspace
|
|
30
28
|
this.jsonInit({
|
|
31
|
-
id:
|
|
29
|
+
id: 'control_forever',
|
|
32
30
|
message0: Blockly.Msg.CONTROL_FOREVER,
|
|
33
|
-
message1:
|
|
34
|
-
message2:
|
|
35
|
-
lastDummyAlign2:
|
|
31
|
+
message1: '%1', // Statement
|
|
32
|
+
message2: '%1', // Icon
|
|
33
|
+
lastDummyAlign2: 'RIGHT',
|
|
36
34
|
args1: [
|
|
37
35
|
{
|
|
38
|
-
type:
|
|
39
|
-
name:
|
|
36
|
+
type: 'input_statement',
|
|
37
|
+
name: 'SUBSTACK',
|
|
40
38
|
},
|
|
41
39
|
],
|
|
42
40
|
args2: [
|
|
43
41
|
{
|
|
44
|
-
type:
|
|
45
|
-
src: ws.options.pathToMedia +
|
|
42
|
+
type: 'field_image',
|
|
43
|
+
src: ws.options.pathToMedia + 'repeat.svg',
|
|
46
44
|
width: 24,
|
|
47
45
|
height: 24,
|
|
48
|
-
alt:
|
|
46
|
+
alt: '*',
|
|
49
47
|
flip_rtl: true,
|
|
50
48
|
},
|
|
51
49
|
],
|
|
52
|
-
extensions: [
|
|
53
|
-
})
|
|
50
|
+
extensions: ['colours_control', 'shape_end'],
|
|
51
|
+
})
|
|
54
52
|
},
|
|
55
|
-
}
|
|
53
|
+
}
|
|
56
54
|
|
|
57
|
-
Blockly.Blocks
|
|
55
|
+
Blockly.Blocks.control_repeat = {
|
|
58
56
|
/**
|
|
59
57
|
* Block for repeat n times (external number).
|
|
60
58
|
* https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#so57n9
|
|
61
59
|
*/
|
|
62
60
|
init: function (this: Blockly.Block) {
|
|
63
|
-
const ws = this.workspace.options.parentWorkspace || this.workspace
|
|
61
|
+
const ws = this.workspace.options.parentWorkspace || this.workspace
|
|
64
62
|
this.jsonInit({
|
|
65
|
-
id:
|
|
63
|
+
id: 'control_repeat',
|
|
66
64
|
message0: Blockly.Msg.CONTROL_REPEAT,
|
|
67
|
-
message1:
|
|
68
|
-
message2:
|
|
69
|
-
lastDummyAlign2:
|
|
65
|
+
message1: '%1', // Statement
|
|
66
|
+
message2: '%1', // Icon
|
|
67
|
+
lastDummyAlign2: 'RIGHT',
|
|
70
68
|
args0: [
|
|
71
69
|
{
|
|
72
|
-
type:
|
|
73
|
-
name:
|
|
70
|
+
type: 'input_value',
|
|
71
|
+
name: 'TIMES',
|
|
74
72
|
},
|
|
75
73
|
],
|
|
76
74
|
args1: [
|
|
77
75
|
{
|
|
78
|
-
type:
|
|
79
|
-
name:
|
|
76
|
+
type: 'input_statement',
|
|
77
|
+
name: 'SUBSTACK',
|
|
80
78
|
},
|
|
81
79
|
],
|
|
82
80
|
args2: [
|
|
83
81
|
{
|
|
84
|
-
type:
|
|
85
|
-
src: ws.options.pathToMedia +
|
|
82
|
+
type: 'field_image',
|
|
83
|
+
src: ws.options.pathToMedia + 'repeat.svg',
|
|
86
84
|
width: 24,
|
|
87
85
|
height: 24,
|
|
88
|
-
alt:
|
|
86
|
+
alt: '*',
|
|
89
87
|
flip_rtl: true,
|
|
90
88
|
},
|
|
91
89
|
],
|
|
92
|
-
extensions: [
|
|
93
|
-
})
|
|
90
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
91
|
+
})
|
|
94
92
|
},
|
|
95
|
-
}
|
|
93
|
+
}
|
|
96
94
|
|
|
97
|
-
Blockly.Blocks
|
|
95
|
+
Blockly.Blocks.control_if = {
|
|
98
96
|
/**
|
|
99
97
|
* Block for if-then.
|
|
100
98
|
*/
|
|
101
99
|
init: function (this: Blockly.Block) {
|
|
102
100
|
this.jsonInit({
|
|
103
|
-
type:
|
|
101
|
+
type: 'control_if',
|
|
104
102
|
message0: Blockly.Msg.CONTROL_IF,
|
|
105
|
-
message1:
|
|
103
|
+
message1: '%1', // Statement
|
|
106
104
|
args0: [
|
|
107
105
|
{
|
|
108
|
-
type:
|
|
109
|
-
name:
|
|
110
|
-
check:
|
|
106
|
+
type: 'input_value',
|
|
107
|
+
name: 'CONDITION',
|
|
108
|
+
check: 'Boolean',
|
|
111
109
|
},
|
|
112
110
|
],
|
|
113
111
|
args1: [
|
|
114
112
|
{
|
|
115
|
-
type:
|
|
116
|
-
name:
|
|
113
|
+
type: 'input_statement',
|
|
114
|
+
name: 'SUBSTACK',
|
|
117
115
|
},
|
|
118
116
|
],
|
|
119
|
-
extensions: [
|
|
120
|
-
})
|
|
117
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
118
|
+
})
|
|
121
119
|
},
|
|
122
|
-
}
|
|
120
|
+
}
|
|
123
121
|
|
|
124
|
-
Blockly.Blocks
|
|
122
|
+
Blockly.Blocks.control_if_else = {
|
|
125
123
|
/**
|
|
126
124
|
* Block for if-else.
|
|
127
125
|
*/
|
|
128
126
|
init: function (this: Blockly.Block) {
|
|
129
127
|
this.jsonInit({
|
|
130
|
-
type:
|
|
128
|
+
type: 'control_if_else',
|
|
131
129
|
message0: Blockly.Msg.CONTROL_IF,
|
|
132
|
-
message1:
|
|
130
|
+
message1: '%1',
|
|
133
131
|
message2: Blockly.Msg.CONTROL_ELSE,
|
|
134
|
-
message3:
|
|
132
|
+
message3: '%1',
|
|
135
133
|
args0: [
|
|
136
134
|
{
|
|
137
|
-
type:
|
|
138
|
-
name:
|
|
139
|
-
check:
|
|
135
|
+
type: 'input_value',
|
|
136
|
+
name: 'CONDITION',
|
|
137
|
+
check: 'Boolean',
|
|
140
138
|
},
|
|
141
139
|
],
|
|
142
140
|
args1: [
|
|
143
141
|
{
|
|
144
|
-
type:
|
|
145
|
-
name:
|
|
142
|
+
type: 'input_statement',
|
|
143
|
+
name: 'SUBSTACK',
|
|
146
144
|
},
|
|
147
145
|
],
|
|
148
146
|
args3: [
|
|
149
147
|
{
|
|
150
|
-
type:
|
|
151
|
-
name:
|
|
148
|
+
type: 'input_statement',
|
|
149
|
+
name: 'SUBSTACK2',
|
|
152
150
|
},
|
|
153
151
|
],
|
|
154
|
-
extensions: [
|
|
155
|
-
})
|
|
152
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
153
|
+
})
|
|
156
154
|
},
|
|
157
|
-
}
|
|
155
|
+
}
|
|
158
156
|
|
|
159
|
-
Blockly.Blocks
|
|
157
|
+
Blockly.Blocks.control_stop = {
|
|
160
158
|
/**
|
|
161
159
|
* Block for stop all scripts.
|
|
162
160
|
*/
|
|
163
161
|
init: function (this: Blockly.Block) {
|
|
164
|
-
const ALL_SCRIPTS =
|
|
165
|
-
const THIS_SCRIPT =
|
|
166
|
-
const OTHER_SCRIPTS =
|
|
162
|
+
const ALL_SCRIPTS = 'all'
|
|
163
|
+
const THIS_SCRIPT = 'this script'
|
|
164
|
+
const OTHER_SCRIPTS = 'other scripts in sprite'
|
|
167
165
|
const stopDropdown = new Blockly.FieldDropdown(
|
|
168
166
|
function () {
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
-
this.sourceBlock_.nextConnection &&
|
|
172
|
-
this.sourceBlock_.nextConnection.isConnected()
|
|
173
|
-
) {
|
|
174
|
-
return [[Blockly.Msg.CONTROL_STOP_OTHER, OTHER_SCRIPTS]];
|
|
167
|
+
if (this.sourceBlock_ && this.sourceBlock_.nextConnection && this.sourceBlock_.nextConnection.isConnected()) {
|
|
168
|
+
return [[Blockly.Msg.CONTROL_STOP_OTHER, OTHER_SCRIPTS]]
|
|
175
169
|
}
|
|
176
170
|
return [
|
|
177
171
|
[Blockly.Msg.CONTROL_STOP_ALL, ALL_SCRIPTS],
|
|
178
172
|
[Blockly.Msg.CONTROL_STOP_THIS, THIS_SCRIPT],
|
|
179
173
|
[Blockly.Msg.CONTROL_STOP_OTHER, OTHER_SCRIPTS],
|
|
180
|
-
]
|
|
174
|
+
]
|
|
181
175
|
},
|
|
182
176
|
function (this: Blockly.FieldDropdown, option: string) {
|
|
183
|
-
const sourceBlock = this.getSourceBlock()
|
|
177
|
+
const sourceBlock = this.getSourceBlock()
|
|
184
178
|
if (sourceBlock) {
|
|
185
|
-
sourceBlock.setNextStatement(option === OTHER_SCRIPTS)
|
|
179
|
+
sourceBlock.setNextStatement(option === OTHER_SCRIPTS)
|
|
186
180
|
} else {
|
|
187
|
-
console.warn(
|
|
188
|
-
"control_stop dropdown callback: source block not found"
|
|
189
|
-
);
|
|
181
|
+
console.warn('control_stop dropdown callback: source block not found')
|
|
190
182
|
}
|
|
191
|
-
return option
|
|
192
|
-
}
|
|
193
|
-
)
|
|
194
|
-
this.appendDummyInput()
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
this.setStyle("control");
|
|
198
|
-
this.setPreviousStatement(true);
|
|
183
|
+
return option
|
|
184
|
+
},
|
|
185
|
+
)
|
|
186
|
+
this.appendDummyInput().appendField(Blockly.Msg.CONTROL_STOP).appendField(stopDropdown, 'STOP_OPTION')
|
|
187
|
+
this.setStyle('control')
|
|
188
|
+
this.setPreviousStatement(true)
|
|
199
189
|
},
|
|
200
|
-
}
|
|
190
|
+
}
|
|
201
191
|
|
|
202
|
-
Blockly.Blocks
|
|
192
|
+
Blockly.Blocks.control_wait = {
|
|
203
193
|
/**
|
|
204
194
|
* Block to wait (pause) stack.
|
|
205
195
|
*/
|
|
206
196
|
init: function (this: Blockly.Block) {
|
|
207
197
|
this.jsonInit({
|
|
208
|
-
id:
|
|
198
|
+
id: 'control_wait',
|
|
209
199
|
message0: Blockly.Msg.CONTROL_WAIT,
|
|
210
200
|
args0: [
|
|
211
201
|
{
|
|
212
|
-
type:
|
|
213
|
-
name:
|
|
202
|
+
type: 'input_value',
|
|
203
|
+
name: 'DURATION',
|
|
214
204
|
},
|
|
215
205
|
],
|
|
216
|
-
extensions: [
|
|
217
|
-
})
|
|
206
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
207
|
+
})
|
|
218
208
|
},
|
|
219
|
-
}
|
|
209
|
+
}
|
|
220
210
|
|
|
221
|
-
Blockly.Blocks
|
|
211
|
+
Blockly.Blocks.control_wait_until = {
|
|
222
212
|
/**
|
|
223
213
|
* Block to wait until a condition becomes true.
|
|
224
214
|
*/
|
|
@@ -227,165 +217,165 @@ Blockly.Blocks["control_wait_until"] = {
|
|
|
227
217
|
message0: Blockly.Msg.CONTROL_WAITUNTIL,
|
|
228
218
|
args0: [
|
|
229
219
|
{
|
|
230
|
-
type:
|
|
231
|
-
name:
|
|
232
|
-
check:
|
|
220
|
+
type: 'input_value',
|
|
221
|
+
name: 'CONDITION',
|
|
222
|
+
check: 'Boolean',
|
|
233
223
|
},
|
|
234
224
|
],
|
|
235
|
-
extensions: [
|
|
236
|
-
})
|
|
225
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
226
|
+
})
|
|
237
227
|
},
|
|
238
|
-
}
|
|
228
|
+
}
|
|
239
229
|
|
|
240
|
-
Blockly.Blocks
|
|
230
|
+
Blockly.Blocks.control_repeat_until = {
|
|
241
231
|
/**
|
|
242
232
|
* Block to repeat until a condition becomes true.
|
|
243
233
|
*/
|
|
244
234
|
init: function (this: Blockly.Block) {
|
|
245
|
-
const ws = this.workspace.options.parentWorkspace || this.workspace
|
|
235
|
+
const ws = this.workspace.options.parentWorkspace || this.workspace
|
|
246
236
|
this.jsonInit({
|
|
247
237
|
message0: Blockly.Msg.CONTROL_REPEATUNTIL,
|
|
248
|
-
message1:
|
|
249
|
-
message2:
|
|
250
|
-
lastDummyAlign2:
|
|
238
|
+
message1: '%1',
|
|
239
|
+
message2: '%1',
|
|
240
|
+
lastDummyAlign2: 'RIGHT',
|
|
251
241
|
args0: [
|
|
252
242
|
{
|
|
253
|
-
type:
|
|
254
|
-
name:
|
|
255
|
-
check:
|
|
243
|
+
type: 'input_value',
|
|
244
|
+
name: 'CONDITION',
|
|
245
|
+
check: 'Boolean',
|
|
256
246
|
},
|
|
257
247
|
],
|
|
258
248
|
args1: [
|
|
259
249
|
{
|
|
260
|
-
type:
|
|
261
|
-
name:
|
|
250
|
+
type: 'input_statement',
|
|
251
|
+
name: 'SUBSTACK',
|
|
262
252
|
},
|
|
263
253
|
],
|
|
264
254
|
args2: [
|
|
265
255
|
{
|
|
266
|
-
type:
|
|
267
|
-
src: ws.options.pathToMedia +
|
|
256
|
+
type: 'field_image',
|
|
257
|
+
src: ws.options.pathToMedia + 'repeat.svg',
|
|
268
258
|
width: 24,
|
|
269
259
|
height: 24,
|
|
270
|
-
alt:
|
|
260
|
+
alt: '*',
|
|
271
261
|
flip_rtl: true,
|
|
272
262
|
},
|
|
273
263
|
],
|
|
274
|
-
extensions: [
|
|
275
|
-
})
|
|
264
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
265
|
+
})
|
|
276
266
|
},
|
|
277
|
-
}
|
|
267
|
+
}
|
|
278
268
|
|
|
279
|
-
Blockly.Blocks
|
|
269
|
+
Blockly.Blocks.control_while = {
|
|
280
270
|
/**
|
|
281
271
|
* Block to repeat until a condition becomes false.
|
|
282
272
|
* (This is an obsolete "hacked" block, for compatibility with 2.0.)
|
|
283
273
|
*/
|
|
284
274
|
init: function (this: Blockly.Block) {
|
|
285
|
-
const ws = this.workspace.options.parentWorkspace || this.workspace
|
|
275
|
+
const ws = this.workspace.options.parentWorkspace || this.workspace
|
|
286
276
|
this.jsonInit({
|
|
287
277
|
message0: Blockly.Msg.CONTROL_WHILE,
|
|
288
|
-
message1:
|
|
289
|
-
message2:
|
|
290
|
-
lastDummyAlign2:
|
|
278
|
+
message1: '%1',
|
|
279
|
+
message2: '%1',
|
|
280
|
+
lastDummyAlign2: 'RIGHT',
|
|
291
281
|
args0: [
|
|
292
282
|
{
|
|
293
|
-
type:
|
|
294
|
-
name:
|
|
295
|
-
check:
|
|
283
|
+
type: 'input_value',
|
|
284
|
+
name: 'CONDITION',
|
|
285
|
+
check: 'Boolean',
|
|
296
286
|
},
|
|
297
287
|
],
|
|
298
288
|
args1: [
|
|
299
289
|
{
|
|
300
|
-
type:
|
|
301
|
-
name:
|
|
290
|
+
type: 'input_statement',
|
|
291
|
+
name: 'SUBSTACK',
|
|
302
292
|
},
|
|
303
293
|
],
|
|
304
294
|
args2: [
|
|
305
295
|
{
|
|
306
|
-
type:
|
|
307
|
-
src: ws.options.pathToMedia +
|
|
296
|
+
type: 'field_image',
|
|
297
|
+
src: ws.options.pathToMedia + 'repeat.svg',
|
|
308
298
|
width: 24,
|
|
309
299
|
height: 24,
|
|
310
|
-
alt:
|
|
300
|
+
alt: '*',
|
|
311
301
|
flip_rtl: true,
|
|
312
302
|
},
|
|
313
303
|
],
|
|
314
|
-
extensions: [
|
|
315
|
-
})
|
|
304
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
305
|
+
})
|
|
316
306
|
},
|
|
317
|
-
}
|
|
307
|
+
}
|
|
318
308
|
|
|
319
|
-
Blockly.Blocks
|
|
309
|
+
Blockly.Blocks.control_for_each = {
|
|
320
310
|
/**
|
|
321
311
|
* Block for for-each. This is an obsolete block that is implemented for
|
|
322
312
|
* compatibility with Scratch 2.0 projects.
|
|
323
313
|
*/
|
|
324
314
|
init: function (this: Blockly.Block) {
|
|
325
315
|
this.jsonInit({
|
|
326
|
-
type:
|
|
316
|
+
type: 'control_for_each',
|
|
327
317
|
message0: Blockly.Msg.CONTROL_FOREACH,
|
|
328
|
-
message1:
|
|
318
|
+
message1: '%1',
|
|
329
319
|
args0: [
|
|
330
320
|
{
|
|
331
|
-
type:
|
|
332
|
-
name:
|
|
321
|
+
type: 'field_variable',
|
|
322
|
+
name: 'VARIABLE',
|
|
333
323
|
},
|
|
334
324
|
{
|
|
335
|
-
type:
|
|
336
|
-
name:
|
|
325
|
+
type: 'input_value',
|
|
326
|
+
name: 'VALUE',
|
|
337
327
|
},
|
|
338
328
|
],
|
|
339
329
|
args1: [
|
|
340
330
|
{
|
|
341
|
-
type:
|
|
342
|
-
name:
|
|
331
|
+
type: 'input_statement',
|
|
332
|
+
name: 'SUBSTACK',
|
|
343
333
|
},
|
|
344
334
|
],
|
|
345
|
-
extensions: [
|
|
346
|
-
})
|
|
335
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
336
|
+
})
|
|
347
337
|
},
|
|
348
|
-
}
|
|
338
|
+
}
|
|
349
339
|
|
|
350
|
-
Blockly.Blocks
|
|
340
|
+
Blockly.Blocks.control_start_as_clone = {
|
|
351
341
|
/**
|
|
352
342
|
* Block for "when I start as a clone" hat.
|
|
353
343
|
*/
|
|
354
344
|
init: function (this: Blockly.Block) {
|
|
355
345
|
this.jsonInit({
|
|
356
|
-
id:
|
|
346
|
+
id: 'control_start_as_clone',
|
|
357
347
|
message0: Blockly.Msg.CONTROL_STARTASCLONE,
|
|
358
348
|
args0: [],
|
|
359
|
-
extensions: [
|
|
360
|
-
})
|
|
349
|
+
extensions: ['colours_control', 'shape_hat'],
|
|
350
|
+
})
|
|
361
351
|
},
|
|
362
|
-
}
|
|
352
|
+
}
|
|
363
353
|
|
|
364
354
|
/**
|
|
365
355
|
* Create-clone drop-down menu. Populated dynamically by scratch-gui.
|
|
366
356
|
*/
|
|
367
|
-
Blockly.Blocks
|
|
357
|
+
Blockly.Blocks.control_create_clone_of_menu = {}
|
|
368
358
|
|
|
369
|
-
Blockly.Blocks
|
|
359
|
+
Blockly.Blocks.control_create_clone_of = {
|
|
370
360
|
/**
|
|
371
361
|
* Block for "create clone of..."
|
|
372
362
|
*/
|
|
373
363
|
init: function (this: Blockly.Block) {
|
|
374
364
|
this.jsonInit({
|
|
375
|
-
id:
|
|
365
|
+
id: 'control_start_as_clone',
|
|
376
366
|
message0: Blockly.Msg.CONTROL_CREATECLONEOF,
|
|
377
367
|
args0: [
|
|
378
368
|
{
|
|
379
|
-
type:
|
|
380
|
-
name:
|
|
369
|
+
type: 'input_value',
|
|
370
|
+
name: 'CLONE_OPTION',
|
|
381
371
|
},
|
|
382
372
|
],
|
|
383
|
-
extensions: [
|
|
384
|
-
})
|
|
373
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
374
|
+
})
|
|
385
375
|
},
|
|
386
|
-
}
|
|
376
|
+
}
|
|
387
377
|
|
|
388
|
-
Blockly.Blocks
|
|
378
|
+
Blockly.Blocks.control_delete_this_clone = {
|
|
389
379
|
/**
|
|
390
380
|
* Block for "delete this clone."
|
|
391
381
|
*/
|
|
@@ -393,12 +383,12 @@ Blockly.Blocks["control_delete_this_clone"] = {
|
|
|
393
383
|
this.jsonInit({
|
|
394
384
|
message0: Blockly.Msg.CONTROL_DELETETHISCLONE,
|
|
395
385
|
args0: [],
|
|
396
|
-
extensions: [
|
|
397
|
-
})
|
|
386
|
+
extensions: ['colours_control', 'shape_end'],
|
|
387
|
+
})
|
|
398
388
|
},
|
|
399
|
-
}
|
|
389
|
+
}
|
|
400
390
|
|
|
401
|
-
Blockly.Blocks
|
|
391
|
+
Blockly.Blocks.control_get_counter = {
|
|
402
392
|
/**
|
|
403
393
|
* Block to get the counter value. This is an obsolete block that is
|
|
404
394
|
* implemented for compatibility with Scratch 2.0 projects.
|
|
@@ -406,12 +396,12 @@ Blockly.Blocks["control_get_counter"] = {
|
|
|
406
396
|
init: function (this: Blockly.Block) {
|
|
407
397
|
this.jsonInit({
|
|
408
398
|
message0: Blockly.Msg.CONTROL_COUNTER,
|
|
409
|
-
extensions: [
|
|
410
|
-
})
|
|
399
|
+
extensions: ['colours_control', 'output_number'],
|
|
400
|
+
})
|
|
411
401
|
},
|
|
412
|
-
}
|
|
402
|
+
}
|
|
413
403
|
|
|
414
|
-
Blockly.Blocks
|
|
404
|
+
Blockly.Blocks.control_incr_counter = {
|
|
415
405
|
/**
|
|
416
406
|
* Block to add one to the counter value. This is an obsolete block that is
|
|
417
407
|
* implemented for compatibility with Scratch 2.0 projects.
|
|
@@ -419,12 +409,12 @@ Blockly.Blocks["control_incr_counter"] = {
|
|
|
419
409
|
init: function (this: Blockly.Block) {
|
|
420
410
|
this.jsonInit({
|
|
421
411
|
message0: Blockly.Msg.CONTROL_INCRCOUNTER,
|
|
422
|
-
extensions: [
|
|
423
|
-
})
|
|
412
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
413
|
+
})
|
|
424
414
|
},
|
|
425
|
-
}
|
|
415
|
+
}
|
|
426
416
|
|
|
427
|
-
Blockly.Blocks
|
|
417
|
+
Blockly.Blocks.control_clear_counter = {
|
|
428
418
|
/**
|
|
429
419
|
* Block to clear the counter value. This is an obsolete block that is
|
|
430
420
|
* implemented for compatibility with Scratch 2.0 projects.
|
|
@@ -432,12 +422,12 @@ Blockly.Blocks["control_clear_counter"] = {
|
|
|
432
422
|
init: function (this: Blockly.Block) {
|
|
433
423
|
this.jsonInit({
|
|
434
424
|
message0: Blockly.Msg.CONTROL_CLEARCOUNTER,
|
|
435
|
-
extensions: [
|
|
436
|
-
})
|
|
425
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
426
|
+
})
|
|
437
427
|
},
|
|
438
|
-
}
|
|
428
|
+
}
|
|
439
429
|
|
|
440
|
-
Blockly.Blocks
|
|
430
|
+
Blockly.Blocks.control_all_at_once = {
|
|
441
431
|
/**
|
|
442
432
|
* Block to run the contained script. This is an obsolete block that is
|
|
443
433
|
* implemented for compatibility with Scratch 2.0 projects. Note that
|
|
@@ -453,14 +443,14 @@ Blockly.Blocks["control_all_at_once"] = {
|
|
|
453
443
|
init: function (this: Blockly.Block) {
|
|
454
444
|
this.jsonInit({
|
|
455
445
|
message0: Blockly.Msg.CONTROL_ALLATONCE,
|
|
456
|
-
message1:
|
|
446
|
+
message1: '%1', // Statement
|
|
457
447
|
args1: [
|
|
458
448
|
{
|
|
459
|
-
type:
|
|
460
|
-
name:
|
|
449
|
+
type: 'input_statement',
|
|
450
|
+
name: 'SUBSTACK',
|
|
461
451
|
},
|
|
462
452
|
],
|
|
463
|
-
extensions: [
|
|
464
|
-
})
|
|
453
|
+
extensions: ['colours_control', 'shape_statement'],
|
|
454
|
+
})
|
|
465
455
|
},
|
|
466
|
-
}
|
|
456
|
+
}
|