sb-edit
Version:
Import, edit, and export Scratch project files
631 lines (630 loc) • 24.6 kB
JavaScript
"use strict";
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BlockBase = void 0;
var OpCode_1 = require("./OpCode");
var id_1 = require("./util/id");
var BlockBase = /** @class */ (function () {
function BlockBase(options) {
this.parent = null;
this.next = null;
Object.assign(this, options);
if (!options.id) {
this.id = (0, id_1.generateId)();
}
}
// TODO: fix signature to be more specific in what's returned
BlockBase.getDefaultInput = function (opcode, input) {
if (!(opcode in KnownBlockInputMap))
return;
return KnownBlockInputMap[opcode][input];
};
BlockBase.isKnownBlock = function (opcode) {
return opcode in KnownBlockInputMap;
};
// TODO: Can we reference MyInputs here?
BlockBase.prototype.getDefaultInput = function (input) {
if (this.isKnownBlock()) {
return BlockBase.getDefaultInput(this.opcode, input);
}
};
BlockBase.prototype.isKnownBlock = function () {
return BlockBase.isKnownBlock(this.opcode);
};
Object.defineProperty(BlockBase.prototype, "blocks", {
get: function () {
return __spreadArray([
this
], Object.values(this.inputs).flatMap(function (input) {
if (input.type === "block") {
return input.value;
}
else if (input.type === "blocks" && input.value) {
return input.value;
}
else {
return [];
}
}), true);
},
enumerable: false,
configurable: true
});
Object.defineProperty(BlockBase.prototype, "isHat", {
get: function () {
var hatTypes = [
OpCode_1.OpCode.event_whenflagclicked,
OpCode_1.OpCode.event_whenkeypressed,
OpCode_1.OpCode.event_whenthisspriteclicked,
OpCode_1.OpCode.event_whenstageclicked,
OpCode_1.OpCode.event_whenbackdropswitchesto,
OpCode_1.OpCode.event_whengreaterthan,
OpCode_1.OpCode.event_whenbroadcastreceived,
OpCode_1.OpCode.control_start_as_clone,
OpCode_1.OpCode.procedures_definition
];
return hatTypes.includes(this.opcode);
},
enumerable: false,
configurable: true
});
return BlockBase;
}());
exports.BlockBase = BlockBase;
// TODO: This is largely a copy of the above data, formatted as a runtime
// constant instead of as type information. Is it possible to construct a type
// from the value of this mapping? I don't know enough ts-fu to risk doing so
// in some way that seems to function as it's supposed to but actually isn't
// carrying type information correctly.
var KnownBlockInputMap = (_a = {},
// Motion
_a[OpCode_1.OpCode.motion_movesteps] = {
STEPS: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.motion_turnright] = {
DEGREES: { type: "number", initial: 15 }
},
_a[OpCode_1.OpCode.motion_turnleft] = {
DEGREES: { type: "number", initial: 15 }
},
_a[OpCode_1.OpCode.motion_goto] = {
TO: { type: "goToTarget", initial: "_random_" }
},
_a[OpCode_1.OpCode.motion_gotoxy] = {
X: { type: "number", initial: 0 },
Y: { type: "number", initial: 0 }
},
_a[OpCode_1.OpCode.motion_glideto] = {
SECS: { type: "number", initial: 1 },
TO: { type: "goToTarget", initial: "_random_" }
},
_a[OpCode_1.OpCode.motion_glidesecstoxy] = {
SECS: { type: "number", initial: 1 },
X: { type: "number", initial: 0 },
Y: { type: "number", initial: 0 }
},
_a[OpCode_1.OpCode.motion_pointindirection] = {
DIRECTION: { type: "angle", initial: 90 }
},
_a[OpCode_1.OpCode.motion_pointtowards] = {
TOWARDS: { type: "pointTowardsTarget", initial: "_mouse_" }
},
_a[OpCode_1.OpCode.motion_changexby] = {
DX: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.motion_setx] = {
X: { type: "number", initial: 0 }
},
_a[OpCode_1.OpCode.motion_changeyby] = {
DY: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.motion_sety] = {
Y: { type: "number", initial: 0 }
},
_a[OpCode_1.OpCode.motion_ifonedgebounce] = {},
_a[OpCode_1.OpCode.motion_setrotationstyle] = {
STYLE: { type: "rotationStyle", initial: "left-right" }
},
_a[OpCode_1.OpCode.motion_xposition] = {},
_a[OpCode_1.OpCode.motion_yposition] = {},
_a[OpCode_1.OpCode.motion_direction] = {},
_a[OpCode_1.OpCode.motion_scroll_right] = {
DISTANCE: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.motion_scroll_up] = {
DISTANCE: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.motion_align_scene] = {
ALIGNMENT: { type: "scrollAlignment", initial: "middle" }
},
// Looks
_a[OpCode_1.OpCode.looks_sayforsecs] = {
MESSAGE: { type: "string", initial: "Hello!" },
SECS: { type: "number", initial: 2 }
},
_a[OpCode_1.OpCode.looks_say] = {
MESSAGE: { type: "string", initial: "Hello!" }
},
_a[OpCode_1.OpCode.looks_thinkforsecs] = {
MESSAGE: { type: "string", initial: "Hmm..." },
SECS: { type: "number", initial: 2 }
},
_a[OpCode_1.OpCode.looks_think] = {
MESSAGE: { type: "string", initial: "Hmmm..." }
},
_a[OpCode_1.OpCode.looks_switchcostumeto] = {
COSTUME: { type: "costume", initial: "costume1" }
},
_a[OpCode_1.OpCode.looks_nextcostume] = {},
_a[OpCode_1.OpCode.looks_switchbackdropto] = {
BACKDROP: { type: "backdrop", initial: "backdrop1" }
},
_a[OpCode_1.OpCode.looks_nextbackdrop] = {},
_a[OpCode_1.OpCode.looks_changesizeby] = {
CHANGE: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.looks_setsizeto] = {
SIZE: { type: "number", initial: 100 }
},
_a[OpCode_1.OpCode.looks_changeeffectby] = {
EFFECT: { type: "graphicEffect", initial: "COLOR" },
CHANGE: { type: "number", initial: 25 }
},
_a[OpCode_1.OpCode.looks_seteffectto] = {
EFFECT: { type: "graphicEffect", initial: "COLOR" },
VALUE: { type: "number", initial: 0 }
},
_a[OpCode_1.OpCode.looks_cleargraphiceffects] = {},
_a[OpCode_1.OpCode.looks_show] = {},
_a[OpCode_1.OpCode.looks_hide] = {},
_a[OpCode_1.OpCode.looks_gotofrontback] = {
FRONT_BACK: { type: "frontBackMenu", initial: "front" }
},
_a[OpCode_1.OpCode.looks_goforwardbackwardlayers] = {
FORWARD_BACKWARD: { type: "forwardBackwardMenu", initial: "forward" },
NUM: { type: "number", initial: 1 }
},
_a[OpCode_1.OpCode.looks_costumenumbername] = {
NUMBER_NAME: { type: "costumeNumberName", initial: "number" }
},
_a[OpCode_1.OpCode.looks_backdropnumbername] = {
NUMBER_NAME: { type: "costumeNumberName", initial: "number" }
},
_a[OpCode_1.OpCode.looks_size] = {},
_a[OpCode_1.OpCode.looks_hideallsprites] = {},
_a[OpCode_1.OpCode.looks_switchbackdroptoandwait] = {
BACKDROP: { type: "backdrop", initial: "backdrop1" }
},
_a[OpCode_1.OpCode.looks_changestretchby] = {
CHANGE: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.looks_setstretchto] = {
STRETCH: { type: "number", initial: 0 }
},
// Sound
_a[OpCode_1.OpCode.sound_playuntildone] = {
SOUND_MENU: { type: "sound", initial: "pop" }
},
_a[OpCode_1.OpCode.sound_play] = {
SOUND_MENU: { type: "sound", initial: "sound" }
},
_a[OpCode_1.OpCode.sound_stopallsounds] = {},
_a[OpCode_1.OpCode.sound_changeeffectby] = {
EFFECT: { type: "soundEffect", initial: "PITCH" },
VALUE: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.sound_seteffectto] = {
EFFECT: { type: "soundEffect", initial: "PITCH" },
VALUE: { type: "number", initial: 0 }
},
_a[OpCode_1.OpCode.sound_cleareffects] = {},
_a[OpCode_1.OpCode.sound_changevolumeby] = {
VOLUME: { type: "number", initial: -10 }
},
_a[OpCode_1.OpCode.sound_setvolumeto] = {
VOLUME: { type: "number", initial: 100 }
},
_a[OpCode_1.OpCode.sound_volume] = {},
// Events
_a[OpCode_1.OpCode.event_whenflagclicked] = {},
_a[OpCode_1.OpCode.event_whenkeypressed] = {
KEY_OPTION: { type: "key", initial: "space" }
},
_a[OpCode_1.OpCode.event_whenthisspriteclicked] = {},
_a[OpCode_1.OpCode.event_whenstageclicked] = {},
_a[OpCode_1.OpCode.event_whenbackdropswitchesto] = {
BACKDROP: { type: "backdrop", initial: "backdrop1" }
},
_a[OpCode_1.OpCode.event_whengreaterthan] = {
WHENGREATERTHANMENU: { type: "greaterThanMenu", initial: "LOUDNESS" },
VALUE: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.event_whenbroadcastreceived] = {
BROADCAST_OPTION: { type: "broadcast", initial: "message1" }
},
_a[OpCode_1.OpCode.event_broadcast] = {
BROADCAST_INPUT: { type: "broadcast", initial: "message1" }
},
_a[OpCode_1.OpCode.event_broadcastandwait] = {
BROADCAST_INPUT: { type: "broadcast", initial: "message1" }
},
// Control
_a[OpCode_1.OpCode.control_wait] = {
DURATION: { type: "number", initial: 1 }
},
_a[OpCode_1.OpCode.control_repeat] = {
TIMES: { type: "number", initial: 10 },
SUBSTACK: { type: "blocks", initial: null }
},
_a[OpCode_1.OpCode.control_forever] = {
SUBSTACK: { type: "blocks", initial: null }
},
_a[OpCode_1.OpCode.control_if] = {
CONDITION: { type: "boolean", initial: false },
SUBSTACK: { type: "blocks", initial: null }
},
_a[OpCode_1.OpCode.control_if_else] = {
CONDITION: { type: "boolean", initial: false },
SUBSTACK: { type: "blocks", initial: null },
SUBSTACK2: { type: "blocks", initial: null }
},
_a[OpCode_1.OpCode.control_wait_until] = {
CONDITION: { type: "boolean", initial: false }
},
_a[OpCode_1.OpCode.control_repeat_until] = {
CONDITION: { type: "boolean", initial: false },
SUBSTACK: { type: "blocks", initial: null }
},
_a[OpCode_1.OpCode.control_stop] = {
STOP_OPTION: { type: "stopMenu", initial: "all" }
},
_a[OpCode_1.OpCode.control_start_as_clone] = {},
_a[OpCode_1.OpCode.control_create_clone_of] = {
CLONE_OPTION: { type: "cloneTarget", initial: "_myself_" }
},
_a[OpCode_1.OpCode.control_delete_this_clone] = {},
_a[OpCode_1.OpCode.control_all_at_once] = {
SUBSTACK: { type: "blocks", initial: null }
},
_a[OpCode_1.OpCode.control_for_each] = {
VARIABLE: { type: "variable", initial: { id: "i", name: "i" } },
VALUE: { type: "number", initial: 10 },
SUBSTACK: { type: "blocks", initial: null }
},
_a[OpCode_1.OpCode.control_while] = {
CONDITION: { type: "boolean", initial: false },
SUBSTACK: { type: "blocks", initial: null }
},
// Sensing
_a[OpCode_1.OpCode.sensing_touchingobject] = {
TOUCHINGOBJECTMENU: { type: "touchingTarget", initial: "_mouse_" }
},
_a[OpCode_1.OpCode.sensing_touchingcolor] = {
COLOR: { type: "color", initial: { r: 0x99, g: 0x66, b: 0xff } }
},
_a[OpCode_1.OpCode.sensing_coloristouchingcolor] = {
COLOR: { type: "color", initial: { r: 0x99, g: 0x66, b: 0xff } },
COLOR2: { type: "color", initial: { r: 0xff, g: 0xab, b: 0x19 } }
},
_a[OpCode_1.OpCode.sensing_distanceto] = {
DISTANCETOMENU: { type: "distanceToMenu", initial: "_mouse_" }
},
_a[OpCode_1.OpCode.sensing_askandwait] = {
QUESTION: { type: "string", initial: "What's your name?" }
},
_a[OpCode_1.OpCode.sensing_answer] = {},
_a[OpCode_1.OpCode.sensing_keypressed] = {
KEY_OPTION: { type: "key", initial: "space" }
},
_a[OpCode_1.OpCode.sensing_mousedown] = {},
_a[OpCode_1.OpCode.sensing_mousex] = {},
_a[OpCode_1.OpCode.sensing_mousey] = {},
_a[OpCode_1.OpCode.sensing_setdragmode] = {
DRAG_MODE: { type: "dragModeMenu", initial: "draggable" }
},
_a[OpCode_1.OpCode.sensing_loudness] = {},
_a[OpCode_1.OpCode.sensing_loud] = {},
_a[OpCode_1.OpCode.sensing_timer] = {},
_a[OpCode_1.OpCode.sensing_resettimer] = {},
_a[OpCode_1.OpCode.sensing_of] = {
PROPERTY: { type: "propertyOfMenu", initial: "backdrop #" },
OBJECT: { type: "target", initial: "_stage_" }
},
_a[OpCode_1.OpCode.sensing_current] = {
CURRENTMENU: { type: "currentMenu", initial: "YEAR" }
},
_a[OpCode_1.OpCode.sensing_dayssince2000] = {},
_a[OpCode_1.OpCode.sensing_username] = {},
_a[OpCode_1.OpCode.sensing_userid] = {},
// Operators
_a[OpCode_1.OpCode.operator_add] = {
NUM1: { type: "number", initial: "" },
NUM2: { type: "number", initial: "" }
},
_a[OpCode_1.OpCode.operator_subtract] = {
NUM1: { type: "number", initial: "" },
NUM2: { type: "number", initial: "" }
},
_a[OpCode_1.OpCode.operator_multiply] = {
NUM1: { type: "number", initial: "" },
NUM2: { type: "number", initial: "" }
},
_a[OpCode_1.OpCode.operator_divide] = {
NUM1: { type: "number", initial: "" },
NUM2: { type: "number", initial: "" }
},
_a[OpCode_1.OpCode.operator_random] = {
FROM: { type: "number", initial: 1 },
TO: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.operator_gt] = {
OPERAND1: { type: "number", initial: "" },
OPERAND2: { type: "number", initial: 50 }
},
_a[OpCode_1.OpCode.operator_lt] = {
OPERAND1: { type: "number", initial: "" },
OPERAND2: { type: "number", initial: 50 }
},
_a[OpCode_1.OpCode.operator_equals] = {
OPERAND1: { type: "number", initial: "" },
OPERAND2: { type: "number", initial: 50 }
},
_a[OpCode_1.OpCode.operator_and] = {
OPERAND1: { type: "boolean", initial: false },
OPERAND2: { type: "boolean", initial: false }
},
_a[OpCode_1.OpCode.operator_or] = {
OPERAND1: { type: "boolean", initial: false },
OPERAND2: { type: "boolean", initial: false }
},
_a[OpCode_1.OpCode.operator_not] = {
OPERAND: { type: "boolean", initial: false }
},
_a[OpCode_1.OpCode.operator_join] = {
STRING1: { type: "string", initial: "apple " },
STRING2: { type: "string", initial: "banana" }
},
_a[OpCode_1.OpCode.operator_letter_of] = {
LETTER: { type: "number", initial: 1 },
STRING: { type: "string", initial: "apple" }
},
_a[OpCode_1.OpCode.operator_length] = {
STRING: { type: "string", initial: "apple" }
},
_a[OpCode_1.OpCode.operator_contains] = {
STRING1: { type: "string", initial: "apple" },
STRING2: { type: "string", initial: "a" }
},
_a[OpCode_1.OpCode.operator_mod] = {
NUM1: { type: "number", initial: "" },
NUM2: { type: "number", initial: "" }
},
_a[OpCode_1.OpCode.operator_round] = {
NUM: { type: "number", initial: "" }
},
_a[OpCode_1.OpCode.operator_mathop] = {
OPERATOR: { type: "mathopMenu", initial: "abs" },
NUM: { type: "number", initial: "" }
},
// Data
_a[OpCode_1.OpCode.data_variable] = {
VARIABLE: { type: "variable", initial: { id: "NONEXISTENT_ID", name: "my variable" } }
},
_a[OpCode_1.OpCode.data_setvariableto] = {
VARIABLE: { type: "variable", initial: { id: "NONEXISTENT_ID", name: "my variable" } },
VALUE: { type: "string", initial: "0" }
},
_a[OpCode_1.OpCode.data_changevariableby] = {
VARIABLE: { type: "variable", initial: { id: "NONEXISTENT_ID", name: "my variable" } },
VALUE: { type: "number", initial: 1 }
},
_a[OpCode_1.OpCode.data_showvariable] = {
VARIABLE: { type: "variable", initial: { id: "NONEXISTENT_ID", name: "my variable" } }
},
_a[OpCode_1.OpCode.data_hidevariable] = {
VARIABLE: { type: "variable", initial: { id: "NONEXISTENT_ID", name: "my variable" } }
},
_a[OpCode_1.OpCode.data_listcontents] = {
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } }
},
_a[OpCode_1.OpCode.data_addtolist] = {
ITEM: { type: "string", initial: "thing" },
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } }
},
_a[OpCode_1.OpCode.data_deleteoflist] = {
INDEX: { type: "number", initial: 1 },
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } }
},
_a[OpCode_1.OpCode.data_deletealloflist] = {
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } }
},
_a[OpCode_1.OpCode.data_insertatlist] = {
ITEM: { type: "string", initial: "thing" },
INDEX: { type: "number", initial: 1 },
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } }
},
_a[OpCode_1.OpCode.data_replaceitemoflist] = {
INDEX: { type: "number", initial: 1 },
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } },
ITEM: { type: "string", initial: "thing" }
},
_a[OpCode_1.OpCode.data_itemoflist] = {
INDEX: { type: "number", initial: 1 },
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } }
},
_a[OpCode_1.OpCode.data_itemnumoflist] = {
ITEM: { type: "string", initial: "thing" },
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } }
},
_a[OpCode_1.OpCode.data_lengthoflist] = {
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } }
},
_a[OpCode_1.OpCode.data_listcontainsitem] = {
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } },
ITEM: { type: "string", initial: "thing" }
},
_a[OpCode_1.OpCode.data_showlist] = {
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } }
},
_a[OpCode_1.OpCode.data_hidelist] = {
LIST: { type: "list", initial: { id: "NONEXISTENT_ID", name: "my list" } }
},
// Custom Blocks
_a[OpCode_1.OpCode.procedures_definition] = {
PROCCODE: { type: "string", initial: "hello" },
ARGUMENTS: {
type: "customBlockArguments",
initial: [
{ type: "label", name: "hello" },
{ type: "numberOrString", name: "who", defaultValue: "me" },
{ type: "boolean", name: "casually", defaultValue: false }
]
},
WARP: { type: "boolean", initial: false }
},
_a[OpCode_1.OpCode.procedures_call] = {
PROCCODE: { type: "string", initial: "hello" },
INPUTS: {
type: "customBlockInputValues",
initial: [
{ type: "string", value: "world" },
{ type: "boolean", value: true }
]
}
},
_a[OpCode_1.OpCode.argument_reporter_string_number] = {
VALUE: { type: "string", initial: "who" }
},
_a[OpCode_1.OpCode.argument_reporter_boolean] = {
VALUE: { type: "string", initial: "casually" }
},
// Extension: Music
_a[OpCode_1.OpCode.music_playDrumForBeats] = {
DRUM: { type: "musicDrum", initial: "1" },
BEATS: { type: "number", initial: 0.25 }
},
_a[OpCode_1.OpCode.music_restForBeats] = {
BEATS: { type: "number", initial: 0.25 }
},
_a[OpCode_1.OpCode.music_playNoteForBeats] = {
NOTE: { type: "number", initial: 60 },
BEATS: { type: "number", initial: 0.25 }
},
_a[OpCode_1.OpCode.music_setInstrument] = {
INSTRUMENT: { type: "musicInstrument", initial: "1" }
},
_a[OpCode_1.OpCode.music_setTempo] = {
TEMPO: { type: "number", initial: 60 }
},
_a[OpCode_1.OpCode.music_changeTempo] = {
TEMPO: { type: "number", initial: 20 }
},
_a[OpCode_1.OpCode.music_getTempo] = {},
// Deprecated:
_a[OpCode_1.OpCode.music_midiPlayDrumForBeats] = {
DRUM: { type: "number", initial: 1 },
BEATS: { type: "number", initial: 0.25 }
},
_a[OpCode_1.OpCode.music_midiSetInstrument] = {
INSTRUMENT: { type: "number", initial: 1 }
},
// Extension: Pen
_a[OpCode_1.OpCode.pen_clear] = {},
_a[OpCode_1.OpCode.pen_stamp] = {},
_a[OpCode_1.OpCode.pen_penDown] = {},
_a[OpCode_1.OpCode.pen_penUp] = {},
_a[OpCode_1.OpCode.pen_setPenColorToColor] = {
COLOR: { type: "color", initial: { r: 0x99, g: 0x66, b: 0xff } }
},
_a[OpCode_1.OpCode.pen_changePenColorParamBy] = {
COLOR_PARAM: { type: "penColorParam", initial: "color" },
VALUE: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.pen_setPenColorParamTo] = {
COLOR_PARAM: { type: "penColorParam", initial: "color" },
VALUE: { type: "number", initial: 50 }
},
_a[OpCode_1.OpCode.pen_changePenSizeBy] = {
SIZE: { type: "number", initial: 1 }
},
_a[OpCode_1.OpCode.pen_setPenSizeTo] = {
SIZE: { type: "number", initial: 1 }
},
// Deprecated:
_a[OpCode_1.OpCode.pen_setPenShadeToNumber] = {
SHADE: { type: "number", initial: 50 }
},
_a[OpCode_1.OpCode.pen_changePenShadeBy] = {
SHADE: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.pen_setPenHueToNumber] = {
HUE: { type: "number", initial: 0 }
},
_a[OpCode_1.OpCode.pen_changePenHueBy] = {
HUE: { type: "number", initial: 10 }
},
// Extension: WeDo 2.0
_a[OpCode_1.OpCode.wedo2_motorOnFor] = {
MOTOR_ID: { type: "wedo2MotorId", initial: "motor" },
DURATION: { type: "number", initial: 1 }
},
_a[OpCode_1.OpCode.wedo2_motorOn] = {
MOTOR_ID: { type: "wedo2MotorId", initial: "motor" }
},
_a[OpCode_1.OpCode.wedo2_motorOff] = {
MOTOR_ID: { type: "wedo2MotorId", initial: "motor" }
},
_a[OpCode_1.OpCode.wedo2_startMotorPower] = {
MOTOR_ID: { type: "wedo2MotorId", initial: "motor" },
POWER: { type: "number", initial: 100 }
},
_a[OpCode_1.OpCode.wedo2_setMotorDirection] = {
MOTOR_ID: { type: "wedo2MotorId", initial: "motor" },
MOTOR_DIRECTION: { type: "wedo2MotorDirection", initial: "this way" }
},
_a[OpCode_1.OpCode.wedo2_setLightHue] = {
HUE: { type: "number", initial: 50 }
},
_a[OpCode_1.OpCode.wedo2_whenDistance] = {
OP: { type: "wedo2Op", initial: "<" },
REFERENCE: { type: "number", initial: 50 }
},
_a[OpCode_1.OpCode.wedo2_whenTilted] = {
TILT_DIRECTION_ANY: { type: "wedo2TiltDirectionAny", initial: "any" }
},
_a[OpCode_1.OpCode.wedo2_getDistance] = {},
_a[OpCode_1.OpCode.wedo2_isTilted] = {
TILT_DIRECTION_ANY: { type: "wedo2TiltDirectionAny", initial: "any" }
},
_a[OpCode_1.OpCode.wedo2_getTiltAngle] = {
TILT_DIRECTION: { type: "wedo2TiltDirection", initial: "up" }
},
// Deprecated:
_a[OpCode_1.OpCode.wedo2_playNoteFor] = {
NOTE: { type: "number", initial: 60 },
DURATION: { type: "number", initial: 0.5 }
},
// Extension: Video Sensing
_a[OpCode_1.OpCode.videoSensing_whenMotionGreaterThan] = {
REFERENCE: { type: "number", initial: 10 }
},
_a[OpCode_1.OpCode.videoSensing_videoOn] = {
ATTRIBUTE: { type: "videoSensingAttribute", initial: "motion" },
SUBJECT: { type: "videoSensingSubject", initial: "this sprite" }
},
_a[OpCode_1.OpCode.videoSensing_videoToggle] = {
VIDEO_STATE: { type: "videoSensingVideoState", initial: "on" }
},
_a[OpCode_1.OpCode.videoSensing_setVideoTransparency] = {
TRANSPARENCY: { type: "number", initial: 50 }
},
_a);