|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
goog.provide('Blockly.Blocks.event');
|
|
|
|
|
|
goog.require('Blockly.Blocks');
|
|
|
goog.require('Blockly.Colours');
|
|
|
goog.require('Blockly.constants');
|
|
|
goog.require('Blockly.ScratchBlocks.VerticalExtensions');
|
|
|
|
|
|
Blockly.Blocks['event_whentouchingobject'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.EVENT_WHENTOUCHINGOBJECT,
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "TOUCHINGOBJECTMENU"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_touchingobjectmenu'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": "%1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_dropdown",
|
|
|
"name": "TOUCHINGOBJECTMENU",
|
|
|
"options": [
|
|
|
[Blockly.Msg.SENSING_TOUCHINGOBJECT_POINTER, '_mouse_'],
|
|
|
[Blockly.Msg.SENSING_TOUCHINGOBJECT_EDGE, '_edge_']
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
"extensions": ["colours_event", "output_string"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_whenflagclicked'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"id": "event_whenflagclicked",
|
|
|
"message0": Blockly.Msg.EVENT_WHENFLAGCLICKED,
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": Blockly.mainWorkspace.options.pathToMedia + "blue-flag.svg",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"alt": "flag"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_whenstopclicked'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"id": "event_whenstopclicked",
|
|
|
"message0": "when %1 clicked",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_image",
|
|
|
"src": Blockly.mainWorkspace.options.pathToMedia + "/icons/control_stop.svg",
|
|
|
"width": 24,
|
|
|
"height": 24,
|
|
|
"alt": "stop"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_whenthisspriteclicked'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.EVENT_WHENTHISSPRITECLICKED,
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_whenstageclicked'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.EVENT_WHENSTAGECLICKED,
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_whenbroadcastreceived'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"id": "event_whenbroadcastreceived",
|
|
|
"message0": Blockly.Msg.EVENT_WHENBROADCASTRECEIVED,
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_variable",
|
|
|
"name": "BROADCAST_OPTION",
|
|
|
"variableTypes": [Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE],
|
|
|
"variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_whenbackdropswitchesto'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.EVENT_WHENBACKDROPSWITCHESTO,
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_dropdown",
|
|
|
"name": "BACKDROP",
|
|
|
"options": [
|
|
|
['backdrop1', 'BACKDROP1']
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_whengreaterthan'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.EVENT_WHENGREATERTHAN,
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_dropdown",
|
|
|
"name": "WHENGREATERTHANMENU",
|
|
|
"options": [
|
|
|
[Blockly.Msg.EVENT_WHENGREATERTHAN_LOUDNESS, 'LOUDNESS'],
|
|
|
[Blockly.Msg.EVENT_WHENGREATERTHAN_TIMER, 'TIMER']
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "VALUE"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_broadcast_menu'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": "%1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_variable",
|
|
|
"name": "BROADCAST_OPTION",
|
|
|
"variableTypes": [Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE],
|
|
|
"variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME
|
|
|
}
|
|
|
],
|
|
|
"colour": Blockly.Colours.event.secondary,
|
|
|
"colourSecondary": Blockly.Colours.event.secondary,
|
|
|
"colourTertiary": Blockly.Colours.event.tertiary,
|
|
|
"extensions": ["output_string"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_broadcast'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"id": "event_broadcast",
|
|
|
"message0": Blockly.Msg.EVENT_BROADCAST,
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "BROADCAST_INPUT"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_broadcastandwait'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"message0": Blockly.Msg.EVENT_BROADCASTANDWAIT,
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "BROADCAST_INPUT"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_statement"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_whenkeypressed'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"id": "event_whenkeypressed",
|
|
|
"message0": Blockly.Msg.EVENT_WHENKEYPRESSED,
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_dropdown",
|
|
|
"name": "KEY_OPTION",
|
|
|
"options": [
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_SPACE, 'space'],
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_UP, 'up arrow'],
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_DOWN, 'down arrow'],
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_RIGHT, 'right arrow'],
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_LEFT, 'left arrow'],
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_ANY, 'any'],
|
|
|
['a', 'a'],
|
|
|
['b', 'b'],
|
|
|
['c', 'c'],
|
|
|
['d', 'd'],
|
|
|
['e', 'e'],
|
|
|
['f', 'f'],
|
|
|
['g', 'g'],
|
|
|
['h', 'h'],
|
|
|
['i', 'i'],
|
|
|
['j', 'j'],
|
|
|
['k', 'k'],
|
|
|
['l', 'l'],
|
|
|
['m', 'm'],
|
|
|
['n', 'n'],
|
|
|
['o', 'o'],
|
|
|
['p', 'p'],
|
|
|
['q', 'q'],
|
|
|
['r', 'r'],
|
|
|
['s', 's'],
|
|
|
['t', 't'],
|
|
|
['u', 'u'],
|
|
|
['v', 'v'],
|
|
|
['w', 'w'],
|
|
|
['x', 'x'],
|
|
|
['y', 'y'],
|
|
|
['z', 'z'],
|
|
|
['0', '0'],
|
|
|
['1', '1'],
|
|
|
['2', '2'],
|
|
|
['3', '3'],
|
|
|
['4', '4'],
|
|
|
['5', '5'],
|
|
|
['6', '6'],
|
|
|
['7', '7'],
|
|
|
['8', '8'],
|
|
|
['9', '9']
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_whenkeyhit'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"id": "event_whenkeyhit",
|
|
|
"message0": "when %1 key hit",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_dropdown",
|
|
|
"name": "KEY_OPTION",
|
|
|
"options": [
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_SPACE, 'space'],
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_UP, 'up arrow'],
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_DOWN, 'down arrow'],
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_RIGHT, 'right arrow'],
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_LEFT, 'left arrow'],
|
|
|
[Blockly.Msg.EVENT_WHENKEYPRESSED_ANY, 'any'],
|
|
|
['a', 'a'],
|
|
|
['b', 'b'],
|
|
|
['c', 'c'],
|
|
|
['d', 'd'],
|
|
|
['e', 'e'],
|
|
|
['f', 'f'],
|
|
|
['g', 'g'],
|
|
|
['h', 'h'],
|
|
|
['i', 'i'],
|
|
|
['j', 'j'],
|
|
|
['k', 'k'],
|
|
|
['l', 'l'],
|
|
|
['m', 'm'],
|
|
|
['n', 'n'],
|
|
|
['o', 'o'],
|
|
|
['p', 'p'],
|
|
|
['q', 'q'],
|
|
|
['r', 'r'],
|
|
|
['s', 's'],
|
|
|
['t', 't'],
|
|
|
['u', 'u'],
|
|
|
['v', 'v'],
|
|
|
['w', 'w'],
|
|
|
['x', 'x'],
|
|
|
['y', 'y'],
|
|
|
['z', 'z'],
|
|
|
['0', '0'],
|
|
|
['1', '1'],
|
|
|
['2', '2'],
|
|
|
['3', '3'],
|
|
|
['4', '4'],
|
|
|
['5', '5'],
|
|
|
['6', '6'],
|
|
|
['7', '7'],
|
|
|
['8', '8'],
|
|
|
['9', '9']
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks['event_whenmousescrolled'] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"id": "event_whenmousescrolled",
|
|
|
"message0": "when mouse is scrolled %1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "field_dropdown",
|
|
|
"name": "KEY_OPTION",
|
|
|
"options": [
|
|
|
['up', 'up'],
|
|
|
['down', 'down']
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks["event_always"] = {
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"inputsInline": true,
|
|
|
"message0": "always",
|
|
|
"args0": [],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks["event_whenanything"] = {
|
|
|
init: function() {
|
|
|
this.jsonInit({
|
|
|
"inputsInline": true,
|
|
|
"message0": "when %1",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "ANYTHING",
|
|
|
"check": "Boolean"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks["event_whenjavascript"] = {
|
|
|
init: function () {
|
|
|
this.jsonInit({
|
|
|
"inputsInline": true,
|
|
|
"message0": "when javascript %1 === true",
|
|
|
"args0": [
|
|
|
{
|
|
|
"type": "input_value",
|
|
|
"name": "JS"
|
|
|
}
|
|
|
],
|
|
|
"category": Blockly.Categories.event,
|
|
|
"extensions": ["colours_event", "shape_hat"]
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|