mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-07-24 20:59:16 -04:00
113 lines
2.8 KiB
JavaScript
113 lines
2.8 KiB
JavaScript
|
/**
|
||
|
* @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": "when %1 clicked",
|
||
|
"args0": [
|
||
|
{
|
||
|
"type": "field_image",
|
||
|
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/event_whenflagclicked.svg",
|
||
|
"width": 20,
|
||
|
"height": 20,
|
||
|
"alt": "flag",
|
||
|
"flip_rtl": true
|
||
|
}
|
||
|
],
|
||
|
"inputsInline": true,
|
||
|
"nextStatement": null,
|
||
|
"colour": Blockly.Colours.event.primary,
|
||
|
"colourSecondary": Blockly.Colours.event.secondary,
|
||
|
"colourTertiary": Blockly.Colours.event.tertiary
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Blockly.Blocks['event_whenbroadcastreceived'] = {
|
||
|
/**
|
||
|
* Block for when broadcast received.
|
||
|
* @this Blockly.Block
|
||
|
*/
|
||
|
init: function() {
|
||
|
this.jsonInit({
|
||
|
"id": "event_whenbroadcastreceived",
|
||
|
"message0": "when I receive ...",
|
||
|
"args0": [
|
||
|
],
|
||
|
"inputsInline": true,
|
||
|
"nextStatement": null,
|
||
|
"colour": Blockly.Colours.event.primary,
|
||
|
"colourSecondary": Blockly.Colours.event.secondary,
|
||
|
"colourTertiary": Blockly.Colours.event.tertiary
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Blockly.Blocks['event_broadcast'] = {
|
||
|
/**
|
||
|
* Block to send a broadcast.
|
||
|
* @this Blockly.Block
|
||
|
*/
|
||
|
init: function() {
|
||
|
this.jsonInit({
|
||
|
"id": "event_broadcast",
|
||
|
"message0": "broadcast ...",
|
||
|
"args0": [
|
||
|
],
|
||
|
"inputsInline": true,
|
||
|
"previousStatement": null,
|
||
|
"nextStatement": null,
|
||
|
"colour": Blockly.Colours.event.primary,
|
||
|
"colourSecondary": Blockly.Colours.event.secondary,
|
||
|
"colourTertiary": Blockly.Colours.event.tertiary
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Blockly.Blocks['event_broadcast_text'] = {
|
||
|
/**
|
||
|
* Block to send a broadcast, with a text-box for testing fields.
|
||
|
* @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.svg",
|
||
|
"width": 40,
|
||
|
"height": 40,
|
||
|
"alt": "Broadcast"
|
||
|
},
|
||
|
{
|
||
|
"type": "input_value",
|
||
|
"name": "STRING"
|
||
|
}
|
||
|
],
|
||
|
"inputsInline": true,
|
||
|
"previousStatement": null,
|
||
|
"nextStatement": null,
|
||
|
"colour": Blockly.Colours.event.primary,
|
||
|
"colourSecondary": Blockly.Colours.event.secondary,
|
||
|
"colourTertiary": Blockly.Colours.event.tertiary
|
||
|
});
|
||
|
}
|
||
|
};
|