Skip to content

Commit bb1dc8a

Browse files
committed
beepの修正
1 parent 6aa54f2 commit bb1dc8a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/lib/ruby-to-blocks-converter/ev3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ const EV3Converter = {
2121
case 'ev3_beep_note':
2222
if (args.length === 2 && this._isNumberOrBlock(args[0]) && this._isNumberOrBlock(args[1])) {
2323
block = this._createBlock('ev3_beep', 'statement');
24-
this._addNumberInput(block, 'NOTE', 'math_number', args[0], 60);
24+
this._addNoteInput(block, 'NOTE', args[0], 60);
2525
this._addNumberInput(block, 'TIME', 'math_number', args[1], 0.5);
2626
}
2727
break;
2828
}
2929
}
3030
return block;
31-
},
31+
}
3232
};
3333

3434
export default EV3Converter;

src/lib/ruby-to-blocks-converter/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,22 @@ class RubyToBlocksConverter {
462462
this._addInput(block, name, this._createNumberBlock(opcode, inputValue), shadowBlock);
463463
}
464464

465+
_addNoteInput (block, name, inputValue, shadowValue) {
466+
let shadowBlock;
467+
let opcode = 'note';
468+
if (!this._isNumber(inputValue)) {
469+
shadowBlock = this._createNoteBlock(opcode, shadowValue);
470+
}
471+
this._addInput(block, name, this._createNoteBlock(opcode, inputValue), shadowBlock);
472+
}
473+
474+
_createNoteBlock (opcode, value) {
475+
if (this._isNumber(value) || value === '') {
476+
return this._createFieldBlock(opcode, 'NOTE', value.toString());
477+
}
478+
return value;
479+
}
480+
465481
_addTextInput (block, name, inputValue, shadowValue) {
466482
let shadowBlock;
467483
if (!this._isString(inputValue)) {

0 commit comments

Comments
 (0)