@@ -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 . _isStringOrBlock ( args [ 0 ] ) && this . _isNumberOrBlock ( args [ 1 ] ) ) {
15
15
block = this . _createBlock ( 'wedo2_motorOnFor' , 'statement' ) ;
16
16
this . _addInput (
17
17
block ,
@@ -22,7 +22,7 @@ const Wedo2Converter = {
22
22
}
23
23
break ;
24
24
case 'wedo2_trun_motor_on' :
25
- if ( args . length === 1 && this . _isString ( args [ 0 ] ) ) {
25
+ if ( args . length === 1 && this . _isStringOrBlock ( args [ 0 ] ) ) {
26
26
block = this . _createBlock ( 'wedo2_motorOn' , 'statement' ) ;
27
27
this . _addInput (
28
28
block ,
@@ -32,7 +32,7 @@ const Wedo2Converter = {
32
32
}
33
33
break ;
34
34
case 'wedo2_trun_motor_off' :
35
- if ( args . length === 1 && this . _isString ( args [ 0 ] ) ) {
35
+ if ( args . length === 1 && this . _isStringOrBlock ( args [ 0 ] ) ) {
36
36
block = this . _createBlock ( 'wedo2_motorOff' , 'statement' ) ;
37
37
this . _addInput (
38
38
block ,
@@ -42,7 +42,7 @@ const Wedo2Converter = {
42
42
}
43
43
break ;
44
44
case 'wedo2_set_motor_power' :
45
- if ( args . length === 2 && this . _isString ( args [ 0 ] ) && this . _isNumberOrBlock ( args [ 1 ] ) ) {
45
+ if ( args . length === 2 && this . _isStringOrBlock ( args [ 0 ] ) && this . _isNumberOrBlock ( args [ 1 ] ) ) {
46
46
block = this . _createBlock ( 'wedo2_startMotorPower' , 'statement' ) ;
47
47
this . _addInput (
48
48
block ,
@@ -53,7 +53,7 @@ const Wedo2Converter = {
53
53
}
54
54
break ;
55
55
case 'wedo2_set_motor_direction' :
56
- if ( args . length === 2 && this . _isString ( args [ 0 ] ) && this . _isString ( args [ 1 ] ) ) {
56
+ if ( args . length === 2 && this . _isStringOrBlock ( args [ 0 ] ) && this . _isStringOrBlock ( args [ 1 ] ) ) {
57
57
block = this . _createBlock ( 'wedo2_setMotorDirection' , 'statement' ) ;
58
58
this . _addInput (
59
59
block ,
@@ -73,6 +73,61 @@ const Wedo2Converter = {
73
73
this . _addNumberInput ( block , 'HUE' , 'math_number' , args [ 0 ] , 50 ) ;
74
74
}
75
75
break ;
76
+ case 'wedo2_distance' :
77
+ if ( args . length === 0 ) {
78
+ block = this . _createBlock ( 'wedo2_getDistance' , 'value' ) ;
79
+ }
80
+ break ;
81
+ case 'wedo2_tilted' :
82
+ if ( args . length === 1 && this . _isStringOrBlock ( args [ 0 ] ) ) {
83
+ block = this . _createBlock ( 'wedo2_isTilted' , 'value' ) ;
84
+ this . _addInput (
85
+ block ,
86
+ 'TILT_DIRECTION_ANY' ,
87
+ this . _createFieldBlock ( 'wedo2_menu_TILT_DIRECTION_ANY' , 'TILT_DIRECTION_ANY' , args [ 0 ] )
88
+ ) ;
89
+ }
90
+ break ;
91
+ case 'wedo2_tilt_angle' :
92
+ if ( args . length === 1 && this . _isStringOrBlock ( args [ 0 ] ) ) {
93
+ block = this . _createBlock ( 'wedo2_getTiltAngle' , 'value' ) ;
94
+ this . _addInput (
95
+ block ,
96
+ 'TILT_DIRECTION' ,
97
+ this . _createFieldBlock ( 'wedo2_menu_TILT_DIRECTION' , 'TILT_DIRECTION' , args [ 0 ] )
98
+ ) ;
99
+ }
100
+ break ;
101
+ }
102
+ } else if ( ( this . _isSelf ( receiver ) || receiver === Opal . nil ) &&
103
+ name === 'when' &&
104
+ args . length >= 1 && args [ 0 ] . type === 'sym' &&
105
+ rubyBlockArgs && rubyBlockArgs . length === 0 &&
106
+ rubyBlock ) {
107
+ switch ( name ) {
108
+ case 'wedo2_when_tilted' :
109
+ if ( args . length === 1 && this . _isStringOrBlock ( args [ 0 ] ) ) {
110
+ block = this . _createBlock ( 'wedo2_whenTilted' , 'hat' ) ;
111
+ this . _addInput (
112
+ block ,
113
+ 'TILT_DIRECTION_ANY' ,
114
+ this . _createFieldBlock ( 'wedo2_menu_TILT_DIRECTION_ANY' , 'TILT_DIRECTION_ANY' , args [ 0 ] )
115
+ ) ;
116
+ this . _setParent ( rubyBlock , block ) ;
117
+ }
118
+ break ;
119
+ case 'wedo2_when_distance' :
120
+ if ( args . length === 2 && this . _isStringOrBlock ( args [ 0 ] ) && this . _isNumberOrBlock ( args [ 1 ] ) ) {
121
+ block = this . _createBlock ( 'wedo2_whenDistance' , 'hat' ) ;
122
+ this . _addInput (
123
+ block ,
124
+ 'OP' ,
125
+ this . _createFieldBlock ( 'wedo2_menu_OP' , 'OP' , args [ 0 ] )
126
+ ) ;
127
+ this . _addNumberInput ( block , 'REFERENCE' , 'math_number' , args [ 1 ] , 50 ) ;
128
+ this . _setParent ( rubyBlock , block ) ;
129
+ }
130
+ break ;
76
131
}
77
132
}
78
133
return block ;
0 commit comments