|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
goog.provide('Blockly.Blocks.control');
|
|
|
|
|
|
goog.require('Blockly.Blocks');
|
|
|
goog.require('Blockly.Colours');
|
|
|
goog.require('Blockly.ScratchBlocks.VerticalExtensions');
|
|
|
|
|
|
|
|
|
Blockly.Blocks['control_forever'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"id": "control_forever",
|
|
|
"message0": Blockly.Msg.CONTROL_FOREVER,
|
|
|
"message1": "%1",
|
|
|
"message2": "%1",
|
|
|
"lastDummyAlign2": "RIGHT",
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"args2": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": Blockly.mainWorkspace.options.pathToMedia + "repeat.svg",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"alt": "*",
|
|
|
"flip_rtl": true
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_end"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_repeat'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"id": "control_repeat",
|
|
|
"message0": Blockly.Msg.CONTROL_REPEAT,
|
|
|
"message1": "%1",
|
|
|
"message2": "%1",
|
|
|
"lastDummyAlign2": "RIGHT",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "TIMES"
|
|
|
}
|
|
|
],
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"args2": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": Blockly.mainWorkspace.options.pathToMedia + "repeat.svg",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"alt": "*",
|
|
|
"flip_rtl": true
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_repeatForSeconds'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"id": "control_repeatForSeconds",
|
|
|
"message0": "repeat for %1 seconds",
|
|
|
"message1": "%1",
|
|
|
"message2": "%1",
|
|
|
"lastDummyAlign2": "RIGHT",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "TIMES"
|
|
|
}
|
|
|
],
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"args2": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": Blockly.mainWorkspace.options.pathToMedia + "repeat.svg",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"alt": "*",
|
|
|
"flip_rtl": true
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_if'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"type": "control_if",
|
|
|
"message0": Blockly.Msg.CONTROL_IF,
|
|
|
"message1": "%1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CONDITION",
|
|
|
"check": "Boolean"
|
|
|
}
|
|
|
],
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_if_else'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"type": "control_if_else",
|
|
|
"message0": Blockly.Msg.CONTROL_IF,
|
|
|
"message1": "%1",
|
|
|
"message2": Blockly.Msg.CONTROL_ELSE,
|
|
|
"message3": "%1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CONDITION",
|
|
|
"check": "Boolean"
|
|
|
}
|
|
|
],
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"args3": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK2"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
Blockly.Blocks['control_try_catch'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"type": "control_try_catch",
|
|
|
"message0": "try to do",
|
|
|
"message1": "%1",
|
|
|
"message2": "if a block errors",
|
|
|
"message3": "%1",
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"args3": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK2"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_throw_error'] = {
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": 'throw error %1',
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "ERROR"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_end"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_error'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": "error",
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "output_string"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_stop'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
var ALL_SCRIPTS = 'all';
|
|
|
var THIS_SCRIPT = 'this script';
|
|
|
var OTHER_SCRIPTS = 'other scripts in sprite';
|
|
|
var stopDropdown = new Blockly.FieldDropdown(function() {
|
|
|
if (this.sourceBlock_ &&
|
|
|
this.sourceBlock_.nextConnection &&
|
|
|
this.sourceBlock_.nextConnection.isConnected()) {
|
|
|
return [
|
|
|
[Blockly.Msg.CONTROL_STOP_OTHER, OTHER_SCRIPTS]
|
|
|
];
|
|
|
}
|
|
|
return [[Blockly.Msg.CONTROL_STOP_ALL, ALL_SCRIPTS],
|
|
|
[Blockly.Msg.CONTROL_STOP_THIS, THIS_SCRIPT],
|
|
|
[Blockly.Msg.CONTROL_STOP_OTHER, OTHER_SCRIPTS]
|
|
|
];
|
|
|
}, function(option) {
|
|
|
|
|
|
|
|
|
Blockly.Events.setGroup(true);
|
|
|
var oldMutation = Blockly.Xml.domToText(this.sourceBlock_.mutationToDom());
|
|
|
this.sourceBlock_.setNextStatement(option == OTHER_SCRIPTS, "normal");
|
|
|
var newMutation = Blockly.Xml.domToText(this.sourceBlock_.mutationToDom());
|
|
|
Blockly.Events.fire(new Blockly.Events.BlockChange(this.sourceBlock_,
|
|
|
'mutation', null, oldMutation, newMutation));
|
|
|
this.setValue(option);
|
|
|
Blockly.Events.setGroup(false);
|
|
|
return null;
|
|
|
});
|
|
|
this.appendDummyInput()
|
|
|
.appendField(Blockly.Msg.CONTROL_STOP)
|
|
|
.appendField(stopDropdown, 'STOP_OPTION');
|
|
|
this.setCategory(Blockly.Categories.control);
|
|
|
this.setColour(Blockly.Colours.control.primary,
|
|
|
Blockly.Colours.control.secondary,
|
|
|
Blockly.Colours.control.tertiary
|
|
|
);
|
|
|
this.setPreviousStatement(true, "normal");
|
|
|
},
|
|
|
mutationToDom: function() {
|
|
|
var container = document.createElement('mutation');
|
|
|
container.setAttribute('hasnext', this.nextConnection != null);
|
|
|
return container;
|
|
|
},
|
|
|
domToMutation: function(xmlElement) {
|
|
|
var hasNext = (xmlElement.getAttribute('hasnext') == 'true');
|
|
|
this.setNextStatement(hasNext, "normal");
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_wait'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"id": "control_wait",
|
|
|
"message0": Blockly.Msg.CONTROL_WAIT,
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "DURATION"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_waitsecondsoruntil'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"id": "control_waitsecondsoruntil",
|
|
|
"message0": "wait %1 seconds or until %2",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "DURATION"
|
|
|
},
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CONDITION",
|
|
|
"check": "Boolean"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_waittick'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"id": "control_waittick",
|
|
|
"message0": "wait until next tick",
|
|
|
"args0": [],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_wait_until'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.CONTROL_WAITUNTIL,
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CONDITION",
|
|
|
"check": "Boolean"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_repeat_until'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.CONTROL_REPEATUNTIL,
|
|
|
"message1": "%1",
|
|
|
"message2": "%1",
|
|
|
"lastDummyAlign2": "RIGHT",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CONDITION",
|
|
|
"check": "Boolean"
|
|
|
}
|
|
|
],
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"args2": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": Blockly.mainWorkspace.options.pathToMedia + "repeat.svg",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"alt": "*",
|
|
|
"flip_rtl": true
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_while'] = {
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.CONTROL_WHILE,
|
|
|
"message1": "%1",
|
|
|
"message2": "%1",
|
|
|
"lastDummyAlign2": "RIGHT",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CONDITION",
|
|
|
"check": "Boolean"
|
|
|
}
|
|
|
],
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"args2": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": Blockly.mainWorkspace.options.pathToMedia + "repeat.svg",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"alt": "*",
|
|
|
"flip_rtl": true
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_for_each'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"type": "control_for_each",
|
|
|
"message0": Blockly.Msg.CONTROL_FOREACH,
|
|
|
"message1": "%1",
|
|
|
"message2": "%1",
|
|
|
"lastDummyAlign2": "RIGHT",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_variable",
|
|
|
"name": "VARIABLE"
|
|
|
},
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "VALUE"
|
|
|
}
|
|
|
],
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"args2": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": Blockly.mainWorkspace.options.pathToMedia + "repeat.svg",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"alt": "*",
|
|
|
"flip_rtl": true
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_start_as_clone'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"id": "control_start_as_clone",
|
|
|
"message0": Blockly.Msg.CONTROL_STARTASCLONE,
|
|
|
"args0": [
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_create_clone_of_menu'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": "%1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_dropdown",
|
|
|
"name": "CLONE_OPTION",
|
|
|
"options": [
|
|
|
[Blockly.Msg.CONTROL_CREATECLONEOF_MYSELF, '_myself_']
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
"extensions": ["colours_control", "output_string"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_create_clone_of'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"id": "control_start_as_clone",
|
|
|
"message0": Blockly.Msg.CONTROL_CREATECLONEOF,
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CLONE_OPTION"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_delete_clones_of'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"id": "control_delete_clones_of",
|
|
|
"message0": "delete clones of %1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CLONE_OPTION"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_delete_this_clone'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.CONTROL_DELETETHISCLONE,
|
|
|
"args0": [
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_end"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_is_clone'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": "is clone?",
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "output_boolean"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_stop_sprite_menu'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": "%1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_dropdown",
|
|
|
"name": "STOP_OPTION",
|
|
|
"options": [
|
|
|
["stage", '_stage_']
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
"extensions": ["colours_control", "output_string"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_stop_sprite'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"id": "control_stop_sprite",
|
|
|
"message0": "stop %1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "STOP_OPTION"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_run_as_sprite_menu'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": "%1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_dropdown",
|
|
|
"name": "RUN_AS_OPTION",
|
|
|
"options": [
|
|
|
["Stage", '_stage_']
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
"extensions": ["colours_control", "output_string"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_run_as_sprite'] = {
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": 'as %1',
|
|
|
"message1": "%1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "RUN_AS_OPTION"
|
|
|
}
|
|
|
],
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_inline_stack_output'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": 'inline block',
|
|
|
"message1": "%1",
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"output": null,
|
|
|
"outputShape": Blockly.OUTPUT_SHAPE_SQUARE,
|
|
|
"extensions": ["colours_control"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_get_counter'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.CONTROL_COUNTER,
|
|
|
"category": Blockly.Categories.control,
|
|
|
"checkboxInFlyout": true,
|
|
|
"extensions": ["colours_control", "output_number"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_incr_counter'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.CONTROL_INCRCOUNTER,
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_decr_counter'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": "decrement counter",
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_set_counter'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": "set counter to %1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "VALUE"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_clear_counter'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.CONTROL_CLEARCOUNTER,
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_all_at_once'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.CONTROL_ALLATONCE,
|
|
|
"message1": "%1",
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_new_script'] = {
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": "new script",
|
|
|
"message1": "%1",
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks["control_backToGreenFlag"] = {
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"inputsInline": true,
|
|
|
"message0": "run %1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAACJ0lEQVRIid2Uy09TQRSHv2kv1VR5hhQQqwlYGtqCmtbHokhDTNQtEVz4B/gfmBCDXoyGmLj3kbBwY2LY6MpHWJDUoBukKsTKQ6I2paWGBipCo73jBii30BpI78ZfMpkzMznznTOPAwZLbFgt/ZWY011k9gzysSdZLICStdJXkPRjSns41hcH2Y7EjmAVmESKFyjyCaPqr50AzBtWbeAsEKDE0oy7w4rnfAXNbWU0nlY40CQwmX0kY73UBr4QGw5vu5vndg31Zy6wv3OGhecZfQbrajk3Rp2zXRdCqe0Irg5o8k8w+uwWR9VLmE13eaeNgarRqtoQ4jKKdpUy+wLy+3Hg2vaAQlIsbk51ZUjNJ/n8egBv5CBan2Bf5TL1nlkafGkWYz8YeVy94bIjwHpOpTY/vs7Nc1WAHQCNr5sXTLsA/EOaNBagabph8QEyYzAA3QkZkYGeUOAVyTlWUt/I/M5gLa/GpDjYXFryuumPaCsgMWsl+ilEfLoOSQTBClBBuW2GExcXsVi9hQFSF8RWQGT8MNCLwzXAYHc2nNabbQzdu4/TH6ThpBMhbDmef1iKhRgf8iHFo/wAeEpIfUgoZ/bD9SAB1Us42MPUiJOaxhBVh5YwKYKfib3MhZtYXS5B0sl79VUhQH4Nq6vADbzqHaJTbUQn3QjKECKOlG8Iqblh7apUsFayX661gjLgH/zPgPm1PlFMQPaSHa4HTIcnSFW8LSbAcP0F3uGqEimnx6MAAAAASUVORK5CYII=",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"flip_rtl": false
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks["control_if_return_else_return"] = {
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"inputsInline": true,
|
|
|
"message0": "if %1 then %2 else %3",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "boolean",
|
|
|
"check": "Boolean"
|
|
|
},
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "TEXT1"
|
|
|
},
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "TEXT2"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "output_string"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_switch'] = {
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": 'switch %1',
|
|
|
"message1": "%1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CONDITION"
|
|
|
}
|
|
|
],
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"name": "SUBSTACK",
|
|
|
"check": 'switchCase'
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_switch_default'] = {
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": 'switch %1',
|
|
|
"message1": "%1",
|
|
|
"message2": "default",
|
|
|
"message3": "%1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CONDITION"
|
|
|
}
|
|
|
],
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"name": "SUBSTACK1",
|
|
|
"check": 'switchCase'
|
|
|
}
|
|
|
],
|
|
|
"args3": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK2"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_case'] = {
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": 'case %1',
|
|
|
"message1": "%1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CONDITION"
|
|
|
}
|
|
|
],
|
|
|
"args1": [
|
|
|
{
|
|
|
"type": "input_statement",
|
|
|
"check": 'normal',
|
|
|
"name": "SUBSTACK"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_case"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_case_next'] = {
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": 'run next case when %1',
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "CONDITION"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_case"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_exitCase'] = {
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": 'exit case %1',
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": Blockly.mainWorkspace.options.pathToMedia + "arrow-down.svg",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"alt": "↓",
|
|
|
"flip_rtl": true
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_end"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_exitLoop'] = {
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": 'escape loop %1',
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": Blockly.mainWorkspace.options.pathToMedia + "arrow-down.svg",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"alt": "↓",
|
|
|
"flip_rtl": true
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_end"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_continueLoop'] = {
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"message0": 'continue loop %1',
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": Blockly.mainWorkspace.options.pathToMedia + "repeat.svg",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"alt": "*",
|
|
|
"flip_rtl": true
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_end"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['control_javascript_command'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": "javascript %1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "JS"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.control,
|
|
|
"extensions": ["colours_control", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|