Skip to content

Commit 002b5a0

Browse files
committed
beepの修正
1 parent 92e56ab commit 002b5a0

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
@@ -464,6 +464,22 @@ class RubyToBlocksConverter {
464464
this._addInput(block, name, this._createNumberBlock(opcode, inputValue), shadowBlock);
465465
}
466466

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

0 commit comments

Comments
 (0)