@@ -21,7 +21,7 @@ const MicroBitConverter = {
2121 this . _addFieldInput (
2222 block , 'BTN' , 'microbit_menu_buttons' , 'buttons' ,
2323 args [ 1 ] , 'A'
24- )
24+ ) ;
2525 this . _setParent ( rubyBlock , block ) ;
2626 }
2727 break ;
@@ -41,7 +41,7 @@ const MicroBitConverter = {
4141 this . _addFieldInput (
4242 block , 'DIRECTION' , 'microbit_menu_tiltDirectionAny' , 'tiltDirectionAny' ,
4343 args [ 1 ] , 'any'
44- )
44+ ) ;
4545 this . _setParent ( rubyBlock , block ) ;
4646 }
4747 break ;
@@ -51,7 +51,7 @@ const MicroBitConverter = {
5151 this . _addFieldInput (
5252 block , 'PIN' , 'microbit_menu_touchPins' , 'touchPins' ,
5353 args [ 1 ] , '0'
54- )
54+ ) ;
5555 this . _setParent ( rubyBlock , block ) ;
5656 }
5757 break ;
@@ -79,14 +79,7 @@ const MicroBitConverter = {
7979 }
8080 break ;
8181 case 'display' :
82- make_display_block:
83- if ( args . length === 5 ) {
84- for ( const arg of args ) {
85- if ( ! this . _isString ( arg ) ) {
86- break make_display_block;
87- }
88- }
89-
82+ if ( args . length === 5 && args . every ( ( i ) => { return this . _isString ( i ) ; } ) ) {
9083 block = this . _changeBlock ( receiver , 'microbit_displaySymbol' , 'statement' ) ;
9184 delete this . _context . blocks [ receiver . inputs . EXPRESSION . block ] ;
9285 delete receiver . inputs . EXPRESSION ;
@@ -95,7 +88,7 @@ const MicroBitConverter = {
9588 for ( const arg of args ) {
9689 matrix += arg ;
9790 }
98- matrix = matrix . replace ( / \. / g, '0' ) ;
91+ matrix = matrix . replace ( / [ 1 - 9 ] / g , '1' ) . replace ( / [ ^ 1 - 9 ] / g, '0' ) ;
9992 this . _addFieldInput (
10093 block , 'MATRIX' , 'matrix' , 'MATRIX' ,
10194 matrix , null
@@ -127,7 +120,7 @@ const MicroBitConverter = {
127120 this . _addFieldInput (
128121 block , 'DIRECTION' , 'microbit_menu_tiltDirectionAny' , 'tiltDirectionAny' ,
129122 args [ 0 ] , 'any'
130- )
123+ ) ;
131124 }
132125 break ;
133126 case 'tilt_angle' :
@@ -139,7 +132,7 @@ const MicroBitConverter = {
139132 this . _addFieldInput (
140133 block , 'DIRECTION' , 'microbit_menu_tiltDirection' , 'tiltDirection' ,
141134 args [ 0 ] , 'front'
142- )
135+ ) ;
143136 }
144137 break ;
145138 }
0 commit comments