Skip to content

Commit dd912b3

Browse files
committed
[ADD] converter of microbit.display function
1 parent 0313b9a commit dd912b3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,30 @@ const MicroBitConverter = {
7979
);
8080
}
8181
break;
82+
case 'display':
83+
make_display_block:
84+
if (args.length === 5) {
85+
for (const arg of args) {
86+
if (!this._isString(arg)) {
87+
break make_display_block;
88+
}
89+
}
90+
91+
block = this._changeBlock(receiver, 'microbit_displaySymbol', 'statement');
92+
delete this._context.blocks[receiver.inputs.EXPRESSION.block];
93+
delete receiver.inputs.EXPRESSION;
94+
95+
var matrix = '';
96+
for (const arg of args) {
97+
matrix += arg;
98+
}
99+
matrix = matrix.replace(/\./g, '0');
100+
this._addFieldInput(
101+
block, 'MATRIX', 'matrix', 'MATRIX',
102+
matrix, null
103+
);
104+
}
105+
break;
82106
case 'display_text':
83107
if (args.length === 1 && this._isString(args[0])) {
84108
block = this._changeBlock(receiver, 'microbit_displayText', 'statement');

0 commit comments

Comments
 (0)