Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ const InputOpcode = {
PM_OP_COMPARE_EXPANDABLE: 'op.compareExpandable',
PM_OP_CHARACTER_TO_CODE: 'op.characterToCode',
PM_OP_CODE_TO_CHARACTER: 'op.codeToCharacter',
PM_OP_COUNT_APPEAR_TIMES: 'op.countAppearTimes',
PM_OP_CONSTRAIN: 'op.constrain',
PM_OP_COUNT_APPEAR_TIMES: 'op.countAppearTimes',
PM_OP_DECODE_B16: 'op.decodeBase16',
PM_OP_DECODE_B64: 'op.decodeBase64',
PM_OP_DECODE_URI: 'op.decodeURI',
Expand Down
15 changes: 14 additions & 1 deletion src/compiler/irgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class ScriptTreeGenerator {
const broadcastOption = block.fields.BROADCAST_OPTION;
const broadcastVariable = this.target.lookupBroadcastMsg(broadcastOption.id, broadcastOption.value);
// TODO: empty string probably isn't the correct fallback
const broadcastName = broadcastVariable ? broadcastVariable.name : '';
const broadcastName = broadcastVariable ? broadcastVariable.name : (broadcastOption.value === 'message1' ? 'message1' : '');
return this.createConstantInput(broadcastName);
}

Expand All @@ -391,6 +391,10 @@ class ScriptTreeGenerator {
return new IntermediateInput(InputOpcode.LOOKS_SIZE_GET, InputType.NUMBER_POS | InputType.NUMBER_ZERO);

//pm looks
case 'looks_backdrops':
return this.createConstantInput(block.fields.BACKDROP.value);
case 'looks_costume':
return this.createConstantInput(block.fields.COSTUME.value);
case 'looks_getEffectValue':
return new IntermediateInput(InputOpcode.PM_LOOKS_GET_EFFECT, InputType.NUMBER, {
effect: block.fields.EFFECT.value.toLowerCase()
Expand Down Expand Up @@ -628,6 +632,13 @@ class ScriptTreeGenerator {
return new IntermediateInput(InputOpcode.PM_OP_CODE_TO_CHARACTER, InputType.STRING, {
one: this.descendInputOfBlock(block, 'ONE').toType(InputType.NUMBER)
});
case 'operator_constant':
switch (block.fields.CONSTANT.value) {
case 'pi': return this.createConstantInput(Math.PI);
case 'euler': return this.createConstantInput(Math.E);
case 'goldenratio': return this.createConstantInput((1 + Math.sqrt(5)) / 2);
}
return this.createConstantInput(0);
case 'operator_countAppearTimes':
return new IntermediateInput(InputOpcode.PM_OP_COUNT_APPEAR_TIMES, InputType.NUMBER, {
text1: this.descendInputOfBlock(block, 'TEXT1').toType(InputType.STRING),
Expand Down Expand Up @@ -1076,6 +1087,8 @@ class ScriptTreeGenerator {
regex: this.descendInputOfBlock(block, 'reg').toType(InputType.STRING),
flags: this.descendInputOfBlock(block, 'regrule').toType(InputType.STRING)
});
case 'sensing_sprites':
return this.createConstantInput(block.fields.SPRITE.value);
case 'sensing_thing_has_number': {
let text = this.descendInputOfBlock(block, 'TEXT1');
if (text.isSubtypeOf(InputType.NUMBER)) return this.createConstantInput(true);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ class Blocks {
return null;
}
const spriteMenuNames = ['TOWARDS', 'TO', 'OBJECT', 'VIDEOONMENU2',
'DISTANCETOMENU', 'TOUCHINGOBJECTMENU', 'CLONE_OPTION'];
'DISTANCETOMENU', 'TOUCHINGOBJECTMENU', 'CLONE_OPTION', 'SPRITE'];
for (let i = 0; i < spriteMenuNames.length; i++) {
const menuName = spriteMenuNames[i];
if (Object.prototype.hasOwnProperty.call(block.fields, menuName)) {
Expand Down