scratch-vm/src/serialization/sb2_specmap.js

1804 lines
42 KiB
JavaScript
Raw Normal View History

2016-08-31 13:56:05 -04:00
/**
* @fileoverview
* The specMap below handles a few pieces of "translation" work between
* the SB2 JSON format and the data we need to run a project
* in the Scratch 3.0 VM.
* Notably:
* - Map 2.0 and 1.4 opcodes (forward:) into 3.0-format (motion_movesteps).
2016-08-31 13:56:05 -04:00
* - Map ordered, unnamed args to unordered, named inputs and fields.
* Keep this up-to-date as 3.0 blocks are renamed, changed, etc.
* Originally this was generated largely by a hand-guided scripting process.
* The relevant data lives here:
* https://github.com/LLK/scratch-flash/blob/master/src/Specs.as
* (for the old opcode and argument order).
* and here:
* https://github.com/LLK/scratch-blocks/tree/develop/blocks_vertical
* (for the new opcodes and argument names).
* and here:
* https://github.com/LLK/scratch-blocks/blob/develop/tests/
* (for the shadow blocks created for each block).
* I started with the `commands` array in Specs.as, and discarded irrelevant
* properties. By hand, I matched the opcode name to the 3.0 opcode.
* Finally, I filled in the expected arguments as below.
2016-08-31 13:56:05 -04:00
*/
2017-11-15 09:17:20 -05:00
const Variable = require('../engine/variable');
/**
* @typedef {object} SB2SpecMap_blockInfo
* @property {string} opcode - the Scratch 3.0 block opcode. Use 'extensionID.opcode' for extension opcodes.
* @property {Array.<SB2SpecMap_argInfo>} argMap - metadata for this block's arguments.
*/
/**
* @typedef {object} SB2SpecMap_argInfo
* @property {string} type - the type of this arg (such as 'input' or 'field')
* @property {string} inputOp - the scratch-blocks shadow type for this arg
* @property {string} inputName - the name this argument will take when provided to the block implementation
*/
/**
* Mapping of Scratch 2.0 opcode to Scratch 3.0 block metadata.
* @type {object.<SB2SpecMap_blockInfo>}
*/
2017-04-17 15:10:04 -04:00
const specMap = {
'forward:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_movesteps',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'STEPS'
2016-08-31 13:56:05 -04:00
}
]
},
'turnRight:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_turnright',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'DEGREES'
2016-08-31 13:56:05 -04:00
}
]
},
'turnLeft:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_turnleft',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'DEGREES'
2016-08-31 13:56:05 -04:00
}
]
},
'heading:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_pointindirection',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_angle',
inputName: 'DIRECTION'
2016-08-31 13:56:05 -04:00
}
]
},
'pointTowards:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_pointtowards',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'motion_pointtowards_menu',
inputName: 'TOWARDS'
2016-08-31 13:56:05 -04:00
}
]
},
'gotoX:y:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_gotoxy',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'X'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'Y'
2016-08-31 13:56:05 -04:00
}
]
},
'gotoSpriteOrMouse:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_goto',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'motion_goto_menu',
inputName: 'TO'
2016-08-31 13:56:05 -04:00
}
]
},
'glideSecs:toX:y:elapsed:from:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_glidesecstoxy',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'SECS'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'X'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'Y'
2016-08-31 13:56:05 -04:00
}
]
},
'changeXposBy:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_changexby',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'DX'
2016-08-31 13:56:05 -04:00
}
]
},
'xpos:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_setx',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'X'
2016-08-31 13:56:05 -04:00
}
]
},
'changeYposBy:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_changeyby',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'DY'
2016-08-31 13:56:05 -04:00
}
]
},
'ypos:': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_sety',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'Y'
2016-08-31 13:56:05 -04:00
}
]
},
'bounceOffEdge': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_ifonedgebounce',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'setRotationStyle': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_setrotationstyle',
argMap: [
2016-08-31 13:56:05 -04:00
{
2017-05-21 12:26:16 -04:00
type: 'field',
fieldName: 'STYLE'
2016-08-31 13:56:05 -04:00
}
]
},
'xpos': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_xposition',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'ypos': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_yposition',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'heading': {
2016-10-24 11:02:19 -04:00
opcode: 'motion_direction',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'scrollRight': {
opcode: 'motion_scroll_right',
argMap: [
{
type: 'input',
inputOp: 'math_number',
inputName: 'DISTANCE'
}
]
},
'scrollUp': {
opcode: 'motion_scroll_up',
argMap: [
{
type: 'input',
inputOp: 'math_number',
inputName: 'DISTANCE'
}
]
},
'scrollAlign': {
opcode: 'motion_align_scene',
argMap: [
{
type: 'field',
fieldName: 'ALIGNMENT'
}
]
},
'xScroll': {
opcode: 'motion_xscroll',
argMap: [
]
},
'yScroll': {
opcode: 'motion_yscroll',
argMap: [
]
},
'say:duration:elapsed:from:': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_sayforsecs',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'MESSAGE'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'SECS'
2016-08-31 13:56:05 -04:00
}
]
},
'say:': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_say',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'MESSAGE'
2016-08-31 13:56:05 -04:00
}
]
},
'think:duration:elapsed:from:': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_thinkforsecs',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'MESSAGE'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'SECS'
2016-08-31 13:56:05 -04:00
}
]
},
'think:': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_think',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'MESSAGE'
2016-08-31 13:56:05 -04:00
}
]
},
'show': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_show',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'hide': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_hide',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'hideAll': {
opcode: 'looks_hideallsprites',
argMap: [
]
},
'lookLike:': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_switchcostumeto',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'looks_costume',
inputName: 'COSTUME'
2016-08-31 13:56:05 -04:00
}
]
},
'nextCostume': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_nextcostume',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'startScene': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_switchbackdropto',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'looks_backdrops',
inputName: 'BACKDROP'
2016-08-31 13:56:05 -04:00
}
]
},
'changeGraphicEffect:by:': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_changeeffectby',
argMap: [
2016-08-31 13:56:05 -04:00
{
2017-05-21 12:26:16 -04:00
type: 'field',
fieldName: 'EFFECT'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'CHANGE'
2016-08-31 13:56:05 -04:00
}
]
},
'setGraphicEffect:to:': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_seteffectto',
argMap: [
2016-08-31 13:56:05 -04:00
{
2017-05-21 12:26:16 -04:00
type: 'field',
fieldName: 'EFFECT'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'VALUE'
2016-08-31 13:56:05 -04:00
}
]
},
'filterReset': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_cleargraphiceffects',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'changeSizeBy:': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_changesizeby',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'CHANGE'
2016-08-31 13:56:05 -04:00
}
]
},
'setSizeTo:': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_setsizeto',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'SIZE'
2016-08-31 13:56:05 -04:00
}
]
},
2018-04-30 20:29:34 -04:00
'changeStretchBy:': {
opcode: 'looks_changestretchby',
argMap: [
{
type: 'input',
inputOp: 'math_number',
inputName: 'CHANGE'
}
]
},
'setStretchTo:': {
opcode: 'looks_setstretchto',
argMap: [
{
type: 'input',
inputOp: 'math_number',
inputName: 'STRETCH'
}
]
},
'comeToFront': {
opcode: 'looks_gotofrontback',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'goBackByLayers:': {
opcode: 'looks_goforwardbackwardlayers',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_integer',
inputName: 'NUM'
2016-08-31 13:56:05 -04:00
}
]
},
'costumeIndex': {
opcode: 'looks_costumenumbername',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
]
},
2018-06-09 20:34:21 -04:00
'costumeName': {
opcode: 'looks_costumenumbername',
2018-06-09 20:34:21 -04:00
argMap: [
]
},
'sceneName': {
opcode: 'looks_backdropnumbername',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'scale': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_size',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'startSceneAndWait': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_switchbackdroptoandwait',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'looks_backdrops',
inputName: 'BACKDROP'
2016-08-31 13:56:05 -04:00
}
]
},
'nextScene': {
2016-10-24 11:02:19 -04:00
opcode: 'looks_nextbackdrop',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'backgroundIndex': {
opcode: 'looks_backdropnumbername',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'playSound:': {
2016-10-24 11:02:19 -04:00
opcode: 'sound_play',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
2016-12-22 14:12:20 -05:00
inputOp: 'sound_sounds_menu',
2016-10-24 11:02:19 -04:00
inputName: 'SOUND_MENU'
2016-08-31 13:56:05 -04:00
}
]
},
'doPlaySoundAndWait': {
2016-10-24 11:02:19 -04:00
opcode: 'sound_playuntildone',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
2016-12-22 14:12:20 -05:00
inputOp: 'sound_sounds_menu',
2016-10-24 11:02:19 -04:00
inputName: 'SOUND_MENU'
2016-08-31 13:56:05 -04:00
}
]
},
'stopAllSounds': {
2016-10-24 11:02:19 -04:00
opcode: 'sound_stopallsounds',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'playDrum': {
2018-04-20 07:54:02 -04:00
opcode: 'music_playDrumForBeats',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
2018-04-20 07:54:02 -04:00
inputOp: 'music_menu_DRUM',
inputName: 'DRUM'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'BEATS'
2016-08-31 13:56:05 -04:00
}
]
},
'rest:elapsed:from:': {
2018-04-20 07:54:02 -04:00
opcode: 'music_restForBeats',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'BEATS'
2016-08-31 13:56:05 -04:00
}
]
},
'noteOn:duration:elapsed:from:': {
2018-04-20 07:54:02 -04:00
opcode: 'music_playNoteForBeats',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'note',
2016-10-24 11:02:19 -04:00
inputName: 'NOTE'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'BEATS'
2016-08-31 13:56:05 -04:00
}
]
},
'instrument:': {
2018-04-20 07:54:02 -04:00
opcode: 'music_setInstrument',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
2018-04-20 07:54:02 -04:00
inputOp: 'music_menu_INSTRUMENT',
2016-10-24 11:02:19 -04:00
inputName: 'INSTRUMENT'
2016-08-31 13:56:05 -04:00
}
]
},
'midiInstrument:': {
opcode: 'music_midiSetInstrument',
argMap: [
{
type: 'input',
inputOp: 'math_number',
inputName: 'INSTRUMENT'
}
]
2016-08-31 13:56:05 -04:00
},
'changeVolumeBy:': {
2016-10-24 11:02:19 -04:00
opcode: 'sound_changevolumeby',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'VOLUME'
2016-08-31 13:56:05 -04:00
}
]
},
'setVolumeTo:': {
2016-10-24 11:02:19 -04:00
opcode: 'sound_setvolumeto',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'VOLUME'
2016-08-31 13:56:05 -04:00
}
]
},
'volume': {
2016-10-24 11:02:19 -04:00
opcode: 'sound_volume',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'changeTempoBy:': {
2018-04-20 07:54:02 -04:00
opcode: 'music_changeTempo',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'TEMPO'
2016-08-31 13:56:05 -04:00
}
]
},
'setTempoTo:': {
2018-04-20 07:54:02 -04:00
opcode: 'music_setTempo',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'TEMPO'
2016-08-31 13:56:05 -04:00
}
]
},
'tempo': {
2018-04-20 07:54:02 -04:00
opcode: 'music_getTempo',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'clearPenTrails': {
2018-04-20 07:54:02 -04:00
opcode: 'pen_clear',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'stampCostume': {
2018-04-20 07:54:02 -04:00
opcode: 'pen_stamp',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'putPenDown': {
2018-04-20 07:54:02 -04:00
opcode: 'pen_penDown',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'putPenUp': {
2018-04-20 07:54:02 -04:00
opcode: 'pen_penUp',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'penColor:': {
2018-04-20 07:54:02 -04:00
opcode: 'pen_setPenColorToColor',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'colour_picker',
inputName: 'COLOR'
2016-08-31 13:56:05 -04:00
}
]
},
'changePenHueBy:': {
2018-04-20 07:54:02 -04:00
opcode: 'pen_changePenHueBy',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
2017-10-31 17:24:12 -04:00
inputName: 'HUE'
2016-08-31 13:56:05 -04:00
}
]
},
'setPenHueTo:': {
2018-04-20 07:54:02 -04:00
opcode: 'pen_setPenHueToNumber',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
2017-10-31 17:24:12 -04:00
inputName: 'HUE'
2016-08-31 13:56:05 -04:00
}
]
},
'changePenShadeBy:': {
2018-04-20 07:54:02 -04:00
opcode: 'pen_changePenShadeBy',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'SHADE'
2016-08-31 13:56:05 -04:00
}
]
},
'setPenShadeTo:': {
2018-04-20 07:54:02 -04:00
opcode: 'pen_setPenShadeToNumber',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'SHADE'
2016-08-31 13:56:05 -04:00
}
]
},
'changePenSizeBy:': {
2018-04-20 07:54:02 -04:00
opcode: 'pen_changePenSizeBy',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'SIZE'
2016-08-31 13:56:05 -04:00
}
]
},
'penSize:': {
2018-04-20 07:54:02 -04:00
opcode: 'pen_setPenSizeTo',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'SIZE'
2016-08-31 13:56:05 -04:00
}
]
},
'senseVideoMotion': {
2018-04-20 07:54:02 -04:00
opcode: 'videoSensing_videoOn',
argMap: [
{
type: 'input',
2018-04-20 07:54:02 -04:00
inputOp: 'videoSensing_menu_ATTRIBUTE',
inputName: 'ATTRIBUTE'
},
{
type: 'input',
2018-04-20 07:54:02 -04:00
inputOp: 'videoSensing_menu_SUBJECT',
inputName: 'SUBJECT'
}
]
},
'whenGreenFlag': {
2016-10-24 11:02:19 -04:00
opcode: 'event_whenflagclicked',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'whenKeyPressed': {
2016-10-24 11:02:19 -04:00
opcode: 'event_whenkeypressed',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'field',
fieldName: 'KEY_OPTION'
2016-08-31 13:56:05 -04:00
}
]
},
'whenClicked': {
2016-10-24 11:02:19 -04:00
opcode: 'event_whenthisspriteclicked',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'whenSceneStarts': {
2016-10-24 11:02:19 -04:00
opcode: 'event_whenbackdropswitchesto',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'field',
fieldName: 'BACKDROP'
2016-08-31 13:56:05 -04:00
}
]
},
'whenSensorGreaterThan': ([, sensor]) => {
if (sensor === 'video motion') {
return {
2018-04-20 07:54:02 -04:00
opcode: 'videoSensing_whenMotionGreaterThan',
argMap: [
// skip the first arg, since we converted to a video specific sensing block
{},
{
type: 'input',
inputOp: 'math_number',
inputName: 'REFERENCE'
}
]
};
}
return {
opcode: 'event_whengreaterthan',
argMap: [
{
type: 'field',
fieldName: 'WHENGREATERTHANMENU'
},
{
type: 'input',
inputOp: 'math_number',
inputName: 'VALUE'
}
]
};
2016-08-31 13:56:05 -04:00
},
'whenIReceive': {
2016-10-24 11:02:19 -04:00
opcode: 'event_whenbroadcastreceived',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'field',
fieldName: 'BROADCAST_OPTION',
variableType: Variable.BROADCAST_MESSAGE_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'broadcast:': {
2016-10-24 11:02:19 -04:00
opcode: 'event_broadcast',
argMap: [
2016-08-31 13:56:05 -04:00
{
type: 'input',
inputOp: 'event_broadcast_menu',
inputName: 'BROADCAST_INPUT',
variableType: Variable.BROADCAST_MESSAGE_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'doBroadcastAndWait': {
2016-10-24 11:02:19 -04:00
opcode: 'event_broadcastandwait',
argMap: [
2016-08-31 13:56:05 -04:00
{
type: 'input',
inputOp: 'event_broadcast_menu',
inputName: 'BROADCAST_INPUT',
variableType: Variable.BROADCAST_MESSAGE_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'wait:elapsed:from:': {
2016-10-24 11:02:19 -04:00
opcode: 'control_wait',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_positive_number',
inputName: 'DURATION'
2016-08-31 13:56:05 -04:00
}
]
},
'doRepeat': {
2016-10-24 11:02:19 -04:00
opcode: 'control_repeat',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_whole_number',
inputName: 'TIMES'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'substack',
2016-10-24 11:02:19 -04:00
inputName: 'SUBSTACK'
2016-08-31 13:56:05 -04:00
}
]
},
'doForever': {
2016-10-24 11:02:19 -04:00
opcode: 'control_forever',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'substack',
2016-10-24 11:02:19 -04:00
inputName: 'SUBSTACK'
2016-08-31 13:56:05 -04:00
}
]
},
'doIf': {
2016-10-24 11:02:19 -04:00
opcode: 'control_if',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'boolean',
2016-10-24 11:02:19 -04:00
inputName: 'CONDITION'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'substack',
2016-10-24 11:02:19 -04:00
inputName: 'SUBSTACK'
2016-08-31 13:56:05 -04:00
}
]
},
'doIfElse': {
2016-10-24 11:02:19 -04:00
opcode: 'control_if_else',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'boolean',
2016-10-24 11:02:19 -04:00
inputName: 'CONDITION'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'substack',
2016-10-24 11:02:19 -04:00
inputName: 'SUBSTACK'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'substack',
2016-10-24 11:02:19 -04:00
inputName: 'SUBSTACK2'
2016-08-31 13:56:05 -04:00
}
]
},
'doWaitUntil': {
2016-10-24 11:02:19 -04:00
opcode: 'control_wait_until',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'boolean',
2016-10-24 11:02:19 -04:00
inputName: 'CONDITION'
2016-08-31 13:56:05 -04:00
}
]
},
'doUntil': {
2016-10-24 11:02:19 -04:00
opcode: 'control_repeat_until',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'boolean',
2016-10-24 11:02:19 -04:00
inputName: 'CONDITION'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'substack',
2016-10-24 11:02:19 -04:00
inputName: 'SUBSTACK'
2016-08-31 13:56:05 -04:00
}
]
},
'doWhile': {
opcode: 'control_while',
argMap: [
{
type: 'input',
inputOp: 'boolean',
inputName: 'CONDITION'
},
{
type: 'input',
inputOp: 'substack',
inputName: 'SUBSTACK'
}
]
},
2018-03-05 16:36:17 -05:00
'doForLoop': {
opcode: 'control_for_each',
argMap: [
{
type: 'field',
fieldName: 'VARIABLE'
},
{
type: 'input',
inputOp: 'text',
inputName: 'VALUE'
},
{
type: 'input',
inputOp: 'substack',
2018-03-05 16:36:17 -05:00
inputName: 'SUBSTACK'
2016-08-31 13:56:05 -04:00
}
]
},
'stopScripts': {
2016-10-24 11:02:19 -04:00
opcode: 'control_stop',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'field',
fieldName: 'STOP_OPTION'
2016-08-31 13:56:05 -04:00
}
]
},
'whenCloned': {
2016-10-24 11:02:19 -04:00
opcode: 'control_start_as_clone',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'createCloneOf': {
2016-10-24 11:02:19 -04:00
opcode: 'control_create_clone_of',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'control_create_clone_of_menu',
inputName: 'CLONE_OPTION'
2016-08-31 13:56:05 -04:00
}
]
},
'deleteClone': {
2016-10-24 11:02:19 -04:00
opcode: 'control_delete_this_clone',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
2018-04-07 15:02:49 -04:00
'COUNT': {
opcode: 'control_get_counter',
argMap: [
]
},
'INCR_COUNT': {
opcode: 'control_incr_counter',
argMap: [
]
},
'CLR_COUNT': {
opcode: 'control_clear_counter',
argMap: [
]
},
2018-04-30 11:18:38 -04:00
'warpSpeed': {
opcode: 'control_all_at_once',
argMap: [
{
type: 'input',
inputOp: 'substack',
2018-04-30 11:18:38 -04:00
inputName: 'SUBSTACK'
}
]
},
'touching:': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_touchingobject',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'sensing_touchingobjectmenu',
inputName: 'TOUCHINGOBJECTMENU'
2016-08-31 13:56:05 -04:00
}
]
},
'touchingColor:': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_touchingcolor',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'colour_picker',
inputName: 'COLOR'
2016-08-31 13:56:05 -04:00
}
]
},
'color:sees:': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_coloristouchingcolor',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'colour_picker',
inputName: 'COLOR'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'colour_picker',
inputName: 'COLOR2'
2016-08-31 13:56:05 -04:00
}
]
},
'distanceTo:': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_distanceto',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'sensing_distancetomenu',
inputName: 'DISTANCETOMENU'
2016-08-31 13:56:05 -04:00
}
]
},
'doAsk': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_askandwait',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'QUESTION'
2016-08-31 13:56:05 -04:00
}
]
},
'answer': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_answer',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'keyPressed:': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_keypressed',
argMap: [
2016-08-31 13:56:05 -04:00
{
type: 'input',
inputOp: 'sensing_keyoptions',
inputName: 'KEY_OPTION'
2016-08-31 13:56:05 -04:00
}
]
},
'mousePressed': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_mousedown',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'mouseX': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_mousex',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'mouseY': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_mousey',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'soundLevel': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_loudness',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
2018-04-30 18:50:13 -04:00
'isLoud': {
opcode: 'sensing_loud',
argMap: [
]
},
// 'senseVideoMotion': {
// opcode: 'sensing_videoon',
// argMap: [
// {
// type: 'input',
// inputOp: 'sensing_videoonmenuone',
// inputName: 'VIDEOONMENU1'
// },
// {
// type: 'input',
// inputOp: 'sensing_videoonmenutwo',
// inputName: 'VIDEOONMENU2'
// }
// ]
// },
'setVideoState': {
2018-04-20 07:54:02 -04:00
opcode: 'videoSensing_videoToggle',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
2018-04-20 10:49:06 -04:00
inputOp: 'videoSensing_menu_VIDEO_STATE',
inputName: 'VIDEO_STATE'
2016-08-31 13:56:05 -04:00
}
]
},
'setVideoTransparency': {
2018-04-20 07:54:02 -04:00
opcode: 'videoSensing_setVideoTransparency',
2016-10-24 11:02:19 -04:00
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'TRANSPARENCY'
2016-08-31 13:56:05 -04:00
}
]
},
'timer': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_timer',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'timerReset': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_resettimer',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'getAttribute:of:': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_of',
argMap: [
2016-08-31 13:56:05 -04:00
{
type: 'field',
fieldName: 'PROPERTY'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'sensing_of_object_menu',
inputName: 'OBJECT'
2016-08-31 13:56:05 -04:00
}
]
},
'timeAndDate': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_current',
argMap: [
2016-08-31 13:56:05 -04:00
{
type: 'field',
fieldName: 'CURRENTMENU'
2016-08-31 13:56:05 -04:00
}
]
},
'timestamp': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_dayssince2000',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'getUserName': {
2016-10-24 11:02:19 -04:00
opcode: 'sensing_username',
argMap: [
2016-08-31 13:56:05 -04:00
]
},
'getUserId': {
opcode: 'sensing_userid',
argMap: [
]
},
'+': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_add',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM1'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM2'
2016-08-31 13:56:05 -04:00
}
]
},
'-': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_subtract',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM1'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM2'
2016-08-31 13:56:05 -04:00
}
]
},
'*': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_multiply',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM1'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM2'
2016-08-31 13:56:05 -04:00
}
]
},
'/': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_divide',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM1'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM2'
2016-08-31 13:56:05 -04:00
}
]
},
'randomFrom:to:': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_random',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'FROM'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'TO'
2016-08-31 13:56:05 -04:00
}
]
},
'<': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_lt',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'OPERAND1'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'OPERAND2'
2016-08-31 13:56:05 -04:00
}
]
},
'=': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_equals',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'OPERAND1'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'OPERAND2'
2016-08-31 13:56:05 -04:00
}
]
},
'>': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_gt',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'OPERAND1'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'OPERAND2'
2016-08-31 13:56:05 -04:00
}
]
},
'&': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_and',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'boolean',
2016-10-24 11:02:19 -04:00
inputName: 'OPERAND1'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'boolean',
2016-10-24 11:02:19 -04:00
inputName: 'OPERAND2'
2016-08-31 13:56:05 -04:00
}
]
},
'|': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_or',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'boolean',
2016-10-24 11:02:19 -04:00
inputName: 'OPERAND1'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'boolean',
2016-10-24 11:02:19 -04:00
inputName: 'OPERAND2'
2016-08-31 13:56:05 -04:00
}
]
},
'not': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_not',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'boolean',
2016-10-24 11:02:19 -04:00
inputName: 'OPERAND'
2016-08-31 13:56:05 -04:00
}
]
},
'concatenate:with:': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_join',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'STRING1'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'STRING2'
2016-08-31 13:56:05 -04:00
}
]
},
'letter:of:': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_letter_of',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_whole_number',
inputName: 'LETTER'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'STRING'
2016-08-31 13:56:05 -04:00
}
]
},
'stringLength:': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_length',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'STRING'
2016-08-31 13:56:05 -04:00
}
]
},
'%': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_mod',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM1'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM2'
2016-08-31 13:56:05 -04:00
}
]
},
'rounded': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_round',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM'
2016-08-31 13:56:05 -04:00
}
]
},
'computeFunction:of:': {
2016-10-24 11:02:19 -04:00
opcode: 'operator_mathop',
argMap: [
2016-08-31 13:56:05 -04:00
{
2017-05-21 12:26:16 -04:00
type: 'field',
fieldName: 'OPERATOR'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'NUM'
2016-08-31 13:56:05 -04:00
}
]
},
'readVariable': {
2016-10-24 11:02:19 -04:00
opcode: 'data_variable',
argMap: [
2016-08-31 13:56:05 -04:00
{
2017-05-21 12:26:16 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'VARIABLE',
2017-11-15 09:17:20 -05:00
variableType: Variable.SCALAR_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
// Scratch 2 uses this alternative variable getter opcode only in monitors,
// blocks use the `readVariable` opcode above.
'getVar:': {
opcode: 'data_variable',
argMap: [
{
type: 'field',
fieldName: 'VARIABLE',
variableType: Variable.SCALAR_TYPE
}
]
},
'setVar:to:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_setvariableto',
argMap: [
2016-08-31 13:56:05 -04:00
{
2017-06-14 16:31:29 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'VARIABLE',
2017-11-15 09:17:20 -05:00
variableType: Variable.SCALAR_TYPE
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'VALUE'
2016-08-31 13:56:05 -04:00
}
]
},
'changeVar:by:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_changevariableby',
argMap: [
2016-08-31 13:56:05 -04:00
{
2017-06-14 16:31:29 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'VARIABLE',
2017-11-15 09:17:20 -05:00
variableType: Variable.SCALAR_TYPE
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_number',
inputName: 'VALUE'
2016-08-31 13:56:05 -04:00
}
]
},
'showVariable:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_showvariable',
argMap: [
2016-08-31 13:56:05 -04:00
{
2017-06-14 16:31:29 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'VARIABLE',
2017-11-15 09:17:20 -05:00
variableType: Variable.SCALAR_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'hideVariable:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_hidevariable',
argMap: [
2016-08-31 13:56:05 -04:00
{
2017-06-14 16:31:29 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'VARIABLE',
2017-11-15 09:17:20 -05:00
variableType: Variable.SCALAR_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'contentsOfList:': {
opcode: 'data_listcontents',
2016-10-24 11:02:19 -04:00
argMap: [
{
2016-10-24 11:02:19 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'LIST',
2017-11-15 09:17:20 -05:00
variableType: Variable.LIST_TYPE
}
]
},
'append:toList:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_addtolist',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'ITEM'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'LIST',
2017-11-15 09:17:20 -05:00
variableType: Variable.LIST_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'deleteLine:ofList:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_deleteoflist',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_integer',
inputName: 'INDEX'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'LIST',
2017-11-15 09:17:20 -05:00
variableType: Variable.LIST_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'insert:at:ofList:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_insertatlist',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'ITEM'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_integer',
inputName: 'INDEX'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'LIST',
2017-11-15 09:17:20 -05:00
variableType: Variable.LIST_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'setLine:ofList:to:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_replaceitemoflist',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_integer',
inputName: 'INDEX'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'LIST',
2017-11-15 09:17:20 -05:00
variableType: Variable.LIST_TYPE
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'ITEM'
2016-08-31 13:56:05 -04:00
}
]
},
'getLine:ofList:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_itemoflist',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'math_integer',
inputName: 'INDEX'
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'LIST',
2017-11-15 09:17:20 -05:00
variableType: Variable.LIST_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'lineCountOfList:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_lengthoflist',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'LIST',
2017-11-15 09:17:20 -05:00
variableType: Variable.LIST_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'list:contains:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_listcontainsitem',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'LIST',
2017-11-15 09:17:20 -05:00
variableType: Variable.LIST_TYPE
2016-08-31 13:56:05 -04:00
},
{
2016-10-24 11:02:19 -04:00
type: 'input',
inputOp: 'text',
inputName: 'ITEM'
2016-08-31 13:56:05 -04:00
}
]
},
'showList:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_showlist',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'LIST',
2017-11-15 09:17:20 -05:00
variableType: Variable.LIST_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'hideList:': {
2016-10-24 11:02:19 -04:00
opcode: 'data_hidelist',
argMap: [
2016-08-31 13:56:05 -04:00
{
2016-10-24 11:02:19 -04:00
type: 'field',
2017-11-13 14:24:30 -05:00
fieldName: 'LIST',
2017-11-15 09:17:20 -05:00
variableType: Variable.LIST_TYPE
2016-08-31 13:56:05 -04:00
}
]
},
'procDef': {
opcode: 'procedures_definition',
2016-10-24 11:02:19 -04:00
argMap: []
2016-08-31 13:56:05 -04:00
},
'getParam': {
// Doesn't map to single opcode. Import step assigns final correct opcode.
opcode: 'argument_reporter_string_number',
argMap: [
{
type: 'field',
fieldName: 'VALUE'
}
]
2016-08-31 13:56:05 -04:00
},
'call': {
opcode: 'procedures_call',
2016-10-24 11:02:19 -04:00
argMap: []
2016-08-31 13:56:05 -04:00
}
};
/**
* Add to the specMap entries for an opcode from a Scratch 2.0 extension. Two entries will be made with the same
* metadata; this is done to support projects saved by both older and newer versions of the Scratch 2.0 editor.
* @param {string} sb2Extension - the Scratch 2.0 name of the extension
* @param {string} sb2Opcode - the Scratch 2.0 opcode
* @param {SB2SpecMap_blockInfo} blockInfo - the Scratch 3.0 block info
*/
const addExtensionOp = function (sb2Extension, sb2Opcode, blockInfo) {
/**
* This string separates the name of an extension and the name of an opcode in more recent Scratch 2.0 projects.
* Earlier projects used '.' as a separator, up until we added the 'LEGO WeDo 2.0' extension...
* @type {string}
*/
const sep = '\u001F'; // Unicode Unit Separator
// make one entry for projects saved by recent versions of the Scratch 2.0 editor
specMap[`${sb2Extension}${sep}${sb2Opcode}`] = blockInfo;
// make a second for projects saved by older versions of the Scratch 2.0 editor
specMap[`${sb2Extension}.${sb2Opcode}`] = blockInfo;
};
const weDo2 = 'LEGO WeDo 2.0';
addExtensionOp(weDo2, 'motorOnFor', {
opcode: 'wedo2_motorOnFor',
argMap: [
{
type: 'input',
inputOp: 'wedo2_menu_MOTOR_ID',
inputName: 'MOTOR_ID'
},
{
type: 'input',
inputOp: 'math_number',
inputName: 'DURATION'
}
]
});
addExtensionOp(weDo2, 'motorOn', {
opcode: 'wedo2_motorOn',
argMap: [
{
type: 'input',
inputOp: 'wedo2_menu_MOTOR_ID',
inputName: 'MOTOR_ID'
}
]
});
addExtensionOp(weDo2, 'motorOff', {
opcode: 'wedo2_motorOff',
argMap: [
{
type: 'input',
inputOp: 'wedo2_menu_MOTOR_ID',
inputName: 'MOTOR_ID'
}
]
});
addExtensionOp(weDo2, 'startMotorPower', {
opcode: 'wedo2_startMotorPower',
argMap: [
{
type: 'input',
inputOp: 'wedo2_menu_MOTOR_ID',
inputName: 'MOTOR_ID'
},
{
type: 'input',
inputOp: 'math_number',
inputName: 'POWER'
}
]
});
addExtensionOp(weDo2, 'setMotorDirection', {
opcode: 'wedo2_setMotorDirection',
argMap: [
{
type: 'input',
inputOp: 'wedo2_menu_MOTOR_ID',
inputName: 'MOTOR_ID'
},
{
type: 'input',
inputOp: 'wedo2_menu_MOTOR_DIRECTION',
inputName: 'MOTOR_DIRECTION'
}
]
});
addExtensionOp(weDo2, 'setLED', {
opcode: 'wedo2_setLightHue',
argMap: [
{
type: 'input',
inputOp: 'math_number',
inputName: 'HUE'
}
]
});
addExtensionOp(weDo2, 'playNote', {
opcode: 'wedo2_playNoteFor',
argMap: [
{
type: 'input',
inputOp: 'math_number',
inputName: 'NOTE'
},
{
type: 'input',
inputOp: 'math_number',
inputName: 'DURATION'
}
]
});
addExtensionOp(weDo2, 'whenDistance', {
opcode: 'wedo2_whenDistance',
argMap: [
{
type: 'input',
inputOp: 'wedo2_menu_OP',
inputName: 'OP'
},
{
type: 'input',
inputOp: 'math_number',
inputName: 'REFERENCE'
}
]
});
addExtensionOp(weDo2, 'whenTilted', {
opcode: 'wedo2_whenTilted',
argMap: [
{
type: 'input',
inputOp: 'wedo2_menu_TILT_DIRECTION_ANY',
inputName: 'TILT_DIRECTION_ANY'
}
]
});
addExtensionOp(weDo2, 'getDistance', {
opcode: 'wedo2_getDistance',
argMap: []
});
addExtensionOp(weDo2, 'isTilted', {
opcode: 'wedo2_isTilted',
argMap: [
{
type: 'input',
inputOp: 'wedo2_menu_TILT_DIRECTION_ANY',
inputName: 'TILT_DIRECTION_ANY'
}
]
});
addExtensionOp(weDo2, 'getTilt', {
opcode: 'wedo2_getTiltAngle',
argMap: [
{
type: 'input',
inputOp: 'wedo2_menu_TILT_DIRECTION',
inputName: 'TILT_DIRECTION'
}
]
});
2016-08-31 13:56:05 -04:00
module.exports = specMap;