Initial commit of 001code-html Scratch frontend project.

Includes scratch-gui, scratch-vm, scratch-blocks, scratch-render, scratch-l10n, and deployment config.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-16 15:37:45 +08:00
commit 6e0a1fbcbb
11350 changed files with 965674 additions and 0 deletions

View File

@@ -0,0 +1,212 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2016 Massachusetts Institute of Technology
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Control blocks for Scratch (Horizontal)
* @author ascii@media.mit.edu <Andrew Sliwinski>
*/
'use strict';
goog.provide('Blockly.Blocks.control');
goog.require('Blockly.Blocks');
goog.require('Blockly.Colours');
Blockly.Blocks['control_repeat'] = {
/**
* Block for repeat n times (external number).
* https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#so57n9
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "control_repeat",
"message0": "%1 %2 %3",
"args0": [
{
"type": "input_statement",
"name": "SUBSTACK"
},
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_repeat.svg",
"width": 40,
"height": 40,
"alt": "*",
"flip_rtl": true
},
{
"type": "input_value",
"name": "TIMES",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"category": Blockly.Categories.control,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary,
"colourQuaternary": Blockly.Colours.control.quaternary
});
}
};
Blockly.Blocks['control_forever'] = {
/**
* Block for repeat n times (external number).
* https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#5eke39
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "control_forever",
"message0": "%1 %2",
"args0": [
{
"type": "input_statement",
"name": "SUBSTACK"
},
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_forever.svg",
"width": 40,
"height": 40,
"alt": "*",
"flip_rtl": true
}
],
"inputsInline": true,
"previousStatement": null,
"category": Blockly.Categories.control,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary,
"colourQuaternary": Blockly.Colours.control.quaternary
});
}
};
Blockly.Blocks['control_repeat'] = {
/**
* Block for repeat n times (external number).
* https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#so57n9
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "control_repeat",
"message0": "%1 %2 %3",
"args0": [
{
"type": "input_statement",
"name": "SUBSTACK"
},
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_repeat.svg",
"width": 40,
"height": 40,
"alt": "*",
"flip_rtl": true
},
{
"type": "input_value",
"name": "TIMES",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"category": Blockly.Categories.control,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary,
"colourQuaternary": Blockly.Colours.control.quaternary
});
}
};
Blockly.Blocks['control_stop'] = {
/**
* Block for stop all scripts.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "control_stop",
"message0": "%1",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_stop.svg",
"width": 40,
"height": 40,
"alt": "Stop"
}
],
"inputsInline": true,
"previousStatement": null,
"category": Blockly.Categories.control,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary,
"colourQuaternary": Blockly.Colours.control.quaternary
});
}
};
Blockly.Blocks['control_wait'] = {
/**
* Block to wait (pause) stack.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "control_wait",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_wait.svg",
"width": 40,
"height": 40,
"alt": "Wait"
},
{
"type": "input_value",
"name": "DURATION",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"category": Blockly.Categories.control,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary,
"colourQuaternary": Blockly.Colours.control.quaternary
});
}
};

View File

@@ -0,0 +1,139 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2016 Massachusetts Institute of Technology
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
goog.provide('Blockly.Blocks.defaultToolbox');
goog.require('Blockly.Blocks');
/**
* @fileoverview Provide a default toolbox XML.
*/
Blockly.Blocks.defaultToolbox = '<xml id="toolbox-categories" style="display: none">' +
'<category name="Events">' +
'<block type="event_whenflagclicked"></block>' +
'<block type="event_whenbroadcastreceived">' +
'<value name="CHOICE">' +
'<shadow type="dropdown_whenbroadcast">' +
'<field name="CHOICE">blue</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'<block type="event_broadcast">' +
'<value name="CHOICE">' +
'<shadow type="dropdown_broadcast">' +
'<field name="CHOICE">blue</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'</category>' +
'<category name="Control">' +
'<block type="control_forever"></block>' +
'<block type="control_repeat">' +
'<value name="TIMES">' +
'<shadow type="math_whole_number">' +
'<field name="NUM">4</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'<block type="control_stop"></block>' +
'<block type="control_wait">' +
'<value name="DURATION">' +
'<shadow type="math_positive_number">' +
'<field name="NUM">1</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'</category>' +
'<category name="Wedo">' +
'<block type="wedo_setcolor">' +
'<value name="CHOICE">' +
'<shadow type="dropdown_wedo_setcolor">' +
'<field name="CHOICE">mystery</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'<block type="wedo_motorclockwise">' +
'<value name="DURATION">' +
'<shadow type="math_positive_number">' +
'<field name="NUM">1</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'<block type="wedo_motorcounterclockwise">' +
'<value name="DURATION">' +
'<shadow type="math_positive_number">' +
'<field name="NUM">1</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'<block type="wedo_motorspeed">' +
'<value name="CHOICE">' +
'<shadow type="dropdown_wedo_motorspeed">' +
'<field name="CHOICE">fast</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'<block type="wedo_whentilt">' +
'<value name="CHOICE">' +
'<shadow type="dropdown_wedo_whentilt">' +
'<field name="CHOICE">forward</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'<block type="wedo_whendistanceclose"></block>' +
'</category>' +
'</xml>';
Blockly.Blocks.defaultToolboxSimple = '<xml id="toolbox-simple" style="display: none">' +
'<block type="event_whenflagclicked"></block>' +
'<block type="event_whenbroadcastreceived">' +
'<value name="CHOICE">' +
'<shadow type="dropdown_whenbroadcast">' +
'<field name="CHOICE">blue</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'<block type="event_broadcast">' +
'<value name="CHOICE">' +
'<shadow type="dropdown_broadcast">' +
'<field name="CHOICE">blue</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'<block type="control_forever"></block>' +
'<block type="control_repeat">' +
'<value name="TIMES">' +
'<shadow type="math_whole_number">' +
'<field name="NUM">4</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'<block type="control_stop"></block>' +
'<block type="control_wait">' +
'<value name="DURATION">' +
'<shadow type="math_positive_number">' +
'<field name="NUM">1</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'</xml>';

View File

@@ -0,0 +1,190 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2016 Massachusetts Institute of Technology
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Control blocks for Scratch (Horizontal)
* @author ascii@media.mit.edu <Andrew Sliwinski>
*/
'use strict';
goog.provide('Blockly.Blocks.event');
goog.require('Blockly.Blocks');
goog.require('Blockly.Colours');
Blockly.Blocks['event_whenflagclicked'] = {
/**
* Block for when flag clicked.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "event_whenflagclicked",
"message0": "%1",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/event_whenflagclicked.svg",
"width": 40,
"height": 40,
"alt": "When green flag clicked",
"flip_rtl": true
}
],
"inputsInline": true,
"nextStatement": null,
"category": Blockly.Categories.event,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary,
"colourQuaternary": Blockly.Colours.event.quaternary
});
}
};
Blockly.Blocks['dropdown_whenbroadcast'] = {
/**
* Block for when broadcast dropdown (used for shadow).
* @this Blockly.Block
*/
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu(
[
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_blue.svg',
value: 'blue', width: 48, height: 48, alt: 'Blue'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_green.svg',
value: 'green', width: 48, height: 48, alt: 'Green'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_coral.svg',
value: 'coral', width: 48, height: 48, alt: 'Coral'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_magenta.svg',
value: 'magenta', width: 48, height: 48, alt: 'Magenta'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_orange.svg',
value: 'orange', width: 48, height: 48, alt: 'Orange'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_purple.svg',
value: 'purple', width: 48, height: 48, alt: 'Purple'}
]), 'CHOICE');
this.setOutput(true);
this.setColour(Blockly.Colours.event.primary,
Blockly.Colours.event.secondary,
Blockly.Colours.event.tertiary,
Blockly.Colours.event.quaternary
);
}
};
Blockly.Blocks['event_whenbroadcastreceived'] = {
/**
* Block for when broadcast received.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "event_whenbroadcastreceived",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/event_when-broadcast-received_blue.svg",
"width": 40,
"height": 40,
"alt": "Broadcast received"
},
{
"type": "input_value",
"name": "CHOICE"
}
],
"inputsInline": true,
"nextStatement": null,
"category": Blockly.Categories.event,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary,
"colourQuaternary": Blockly.Colours.event.quaternary
});
}
};
Blockly.Blocks['dropdown_broadcast'] = {
/**
* Block for broadcast dropdown (used for shadow).
* @this Blockly.Block
*/
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu(
[
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_blue.svg',
value: 'blue', width: 48, height: 48, alt: 'Blue'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_green.svg',
value: 'green', width: 48, height: 48, alt: 'Green'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_coral.svg',
value: 'coral', width: 48, height: 48, alt: 'Coral'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_magenta.svg',
value: 'magenta', width: 48, height: 48, alt: 'Magenta'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_orange.svg',
value: 'orange', width: 48, height: 48, alt: 'Orange'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_purple.svg',
value: 'purple', width: 48, height: 48, alt: 'Purple'}
]), 'CHOICE');
this.setOutput(true);
this.setColour(Blockly.Colours.event.primary,
Blockly.Colours.event.secondary,
Blockly.Colours.event.tertiary,
Blockly.Colours.event.quaternary
);
}
};
Blockly.Blocks['event_broadcast'] = {
/**
* Block to send a broadcast.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "event_broadcast",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/event_broadcast_blue.svg",
"width": 40,
"height": 40,
"alt": "Broadcast"
},
{
"type": "input_value",
"name": "CHOICE"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"category": Blockly.Categories.event,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary,
"colourQuaternary": Blockly.Colours.event.quaternary
});
}
};

View File

@@ -0,0 +1,325 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2016 Massachusetts Institute of Technology
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Wedo blocks for Scratch (Horizontal)
* @author ascii@media.mit.edu <Andrew Sliwinski>
*/
'use strict';
goog.provide('Blockly.Blocks.wedo');
goog.require('Blockly.Blocks');
goog.require('Blockly.Colours');
Blockly.Blocks['dropdown_wedo_setcolor'] = {
/**
* Block for set color drop-down (used for shadow).
* @this Blockly.Block
*/
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu(
[
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_mystery.svg',
value: 'mystery', width: 48, height: 48, alt: 'Mystery'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_yellow.svg',
value: 'yellow', width: 48, height: 48, alt: 'Yellow'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_orange.svg',
value: 'orange', width: 48, height: 48, alt: 'Orange'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_coral.svg',
value: 'coral', width: 48, height: 48, alt: 'Coral'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_magenta.svg',
value: 'magenta', width: 48, height: 48, alt: 'Magenta'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_purple.svg',
value: 'purple', width: 48, height: 48, alt: 'Purple'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_blue.svg',
value: 'blue', width: 48, height: 48, alt: 'Blue'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_green.svg',
value: 'green', width: 48, height: 48, alt: 'Green'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_white.svg',
value: 'white', width: 48, height: 48, alt: 'White'}
]), 'CHOICE');
this.setOutput(true);
this.setColour(Blockly.Colours.looks.primary,
Blockly.Colours.looks.secondary,
Blockly.Colours.looks.tertiary,
Blockly.Colours.looks.quaternary
);
}
};
Blockly.Blocks['wedo_setcolor'] = {
/**
* Block to set color of LED
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_setcolor",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/set-led_blue.svg",
"width": 40,
"height": 40,
"alt": "Set LED Color"
},
{
"type": "input_value",
"name": "CHOICE"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"category": Blockly.Categories.looks,
"colour": Blockly.Colours.looks.primary,
"colourSecondary": Blockly.Colours.looks.secondary,
"colourTertiary": Blockly.Colours.looks.tertiary,
"colourQuaternary": Blockly.Colours.looks.quaternary
});
}
};
Blockly.Blocks['wedo_motorclockwise'] = {
/**
* Block to spin motor clockwise.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_motorclockwise",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/wedo_motor-clockwise.svg",
"width": 40,
"height": 40,
"alt": "Turn motor clockwise"
},
{
"type": "input_value",
"name": "DURATION",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"category": Blockly.Categories.motion,
"colour": Blockly.Colours.motion.primary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary,
"colourQuaternary": Blockly.Colours.motion.quaternary
});
}
};
Blockly.Blocks['wedo_motorcounterclockwise'] = {
/**
* Block to spin motor counter-clockwise.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_motorcounterclockwise",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/wedo_motor-counterclockwise.svg",
"width": 40,
"height": 40,
"alt": "Turn motor counter-clockwise"
},
{
"type": "input_value",
"name": "DURATION",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"category": Blockly.Categories.motion,
"colour": Blockly.Colours.motion.primary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary,
"colourQuaternary": Blockly.Colours.motion.quaternary
});
}
};
Blockly.Blocks['dropdown_wedo_motorspeed'] = {
/**
* Block for motor speed drop-down (used for shadow).
* @this Blockly.Block
*/
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu(
[
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_slow.svg',
value: 'slow', width: 48, height: 48, alt: 'Slow'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_med.svg',
value: 'medium', width: 48, height: 48, alt: 'Medium'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_fast.svg',
value: 'fast', width: 48, height: 48, alt: 'Fast'}
]), 'CHOICE');
this.setOutput(true);
this.setColour(Blockly.Colours.motion.primary,
Blockly.Colours.motion.secondary,
Blockly.Colours.motion.tertiary,
Blockly.Colours.motion.quaternary
);
}
};
Blockly.Blocks['wedo_motorspeed'] = {
/**
* Block to set motor speed.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_motorspeed",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/wedo_motor-speed_fast.svg",
"width": 40,
"height": 40,
"alt": "Motor Speed"
},
{
"type": "input_value",
"name": "CHOICE"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"category": Blockly.Categories.motion,
"colour": Blockly.Colours.motion.primary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary,
"colourQuaternary": Blockly.Colours.motion.quaternary
});
}
};
Blockly.Blocks['dropdown_wedo_whentilt'] = {
/**
* Block for when tilt drop-down (used for shadow).
* @this Blockly.Block
*/
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu(
[
{type: 'placeholder', width: 48, height: 48},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-forward.svg',
value: 'forward', width: 48, height: 48, alt: 'Tilt forward'},
{type: 'placeholder', width: 48, height: 48},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-left.svg',
value: 'left', width: 48, height: 48, alt: 'Tilt left'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt.svg',
value: 'any', width: 48, height: 48, alt: 'Tilt any'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-right.svg',
value: 'right', width: 48, height: 48, alt: 'Tilt right'},
{type: 'placeholder', width: 48, height: 48},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-backward.svg',
value: 'backward', width: 48, height: 48, alt: 'Tilt backward'}
]), 'CHOICE');
this.setOutput(true);
this.setColour(Blockly.Colours.event.primary,
Blockly.Colours.event.secondary,
Blockly.Colours.event.tertiary,
Blockly.Colours.event.quaternary
);
}
};
Blockly.Blocks['wedo_whentilt'] = {
/**
* Block for when tilted.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_whentilt",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/wedo_when-tilt.svg",
"width": 40,
"height": 40,
"alt": "When tilted"
},
{
"type": "input_value",
"name": "CHOICE"
}
],
"inputsInline": true,
"nextStatement": null,
"category": Blockly.Categories.event,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary,
"colourQuaternary": Blockly.Colours.event.quaternary
});
}
};
Blockly.Blocks['wedo_whendistanceclose'] = {
/**
* Block for when distance sensor is close.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_whendistanceclose",
"message0": "%1",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/wedo_when-distance_close.svg",
"width": 40,
"height": 40,
"alt": "When distance close"
}
],
"inputsInline": true,
"nextStatement": null,
"category": Blockly.Categories.event,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary,
"colourQuaternary": Blockly.Colours.event.quaternary
});
}
};