@@ -11,7 +11,7 @@ const Wedo2Converter = {
1111 if ( ( this . _isSelf ( receiver ) || receiver === Opal . nil ) && ! rubyBlock ) {
1212 switch ( name ) {
1313 case 'wedo2_turn_motor_on_for' :
14- if ( args . length === 2 && this . _isString ( args [ 0 ] ) && this . _isNumberOrBlock ( args [ 1 ] ) ) {
14+ if ( args . length === 2 && this . _isString ( args [ 0 ] ) && this . _isNumberOrBlock ( args [ 1 ] ) ) {
1515 block = this . _createBlock ( 'wedo2_motorOnFor' , 'statement' ) ;
1616 this . _addInput (
1717 block ,
@@ -22,24 +22,36 @@ const Wedo2Converter = {
2222 }
2323 break ;
2424 case 'wedo2_trun_motor_on' :
25- block = this . _createBlock ( 'wedo2_motorOn' , 'statement' ) ;
26- this . _addInput ( block , 'MOTOR_ID' , this . _createFieldBlock ( 'wedo2_menu_MOTOR_ID' , 'MOTOR_ID' , args [ 0 ] ) )
25+ if ( args . length === 1 && this . _isString ( args [ 0 ] ) ) {
26+ block = this . _createBlock ( 'wedo2_motorOn' , 'statement' ) ;
27+ this . _addInput (
28+ block ,
29+ 'MOTOR_ID' ,
30+ this . _createFieldBlock ( 'wedo2_menu_MOTOR_ID' , 'MOTOR_ID' , args [ 0 ] )
31+ ) ;
32+ }
2733 break ;
2834 case 'wedo2_trun_motor_off' :
29- block = this . _createBlock ( 'wedo2_motorOff' , 'statement' ) ;
30- this . _addInput ( block , 'MOTOR_ID' , this . _createFieldBlock ( 'wedo2_menu_MOTOR_ID' , 'MOTOR_ID' , args [ 0 ] ) )
35+ if ( args . length === 1 && this . _isString ( args [ 0 ] ) ) {
36+ block = this . _createBlock ( 'wedo2_motorOff' , 'statement' ) ;
37+ this . _addInput (
38+ block ,
39+ 'MOTOR_ID' ,
40+ this . _createFieldBlock ( 'wedo2_menu_MOTOR_ID' , 'MOTOR_ID' , args [ 0 ] )
41+ ) ;
42+ }
3143 break ;
3244 case 'wedo2_set_motor_power' :
33- if ( args . length === 2 && this . _isString ( args [ 0 ] ) && this . _isNumberOrBlock ( args [ 1 ] ) ) {
45+ if ( args . length === 2 && this . _isString ( args [ 0 ] ) && this . _isNumberOrBlock ( args [ 1 ] ) ) {
3446 block = this . _createBlock ( 'wedo2_startMotorPower' , 'statement' ) ;
3547 this . _addInput (
3648 block ,
3749 'MOTOR_ID' ,
3850 this . _createFieldBlock ( 'wedo2_menu_MOTOR_ID' , 'MOTOR_ID' , args [ 0 ] )
3951 ) ;
4052 this . _addNumberInput ( block , 'POWER' , 'math_number' , args [ 1 ] , 100 ) ;
41- break ;
4253 }
54+ break ;
4355 case 'wedo2_set_motor_direction' :
4456 if ( args . length === 2 && this . _isString ( args [ 0 ] ) && this . _isString ( args [ 1 ] ) ) {
4557 block = this . _createBlock ( 'wedo2_setMotorDirection' , 'statement' ) ;
0 commit comments