@@ -11,7 +11,7 @@ const Wedo2Converter = {
11
11
if ( ( this . _isSelf ( receiver ) || receiver === Opal . nil ) && ! rubyBlock ) {
12
12
switch ( name ) {
13
13
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 ] ) ) {
15
15
block = this . _createBlock ( 'wedo2_motorOnFor' , 'statement' ) ;
16
16
this . _addInput (
17
17
block ,
@@ -22,24 +22,36 @@ const Wedo2Converter = {
22
22
}
23
23
break ;
24
24
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
+ }
27
33
break ;
28
34
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
+ }
31
43
break ;
32
44
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 ] ) ) {
34
46
block = this . _createBlock ( 'wedo2_startMotorPower' , 'statement' ) ;
35
47
this . _addInput (
36
48
block ,
37
49
'MOTOR_ID' ,
38
50
this . _createFieldBlock ( 'wedo2_menu_MOTOR_ID' , 'MOTOR_ID' , args [ 0 ] )
39
51
) ;
40
52
this . _addNumberInput ( block , 'POWER' , 'math_number' , args [ 1 ] , 100 ) ;
41
- break ;
42
53
}
54
+ break ;
43
55
case 'wedo2_set_motor_direction' :
44
56
if ( args . length === 2 && this . _isString ( args [ 0 ] ) && this . _isString ( args [ 1 ] ) ) {
45
57
block = this . _createBlock ( 'wedo2_setMotorDirection' , 'statement' ) ;
0 commit comments