@@ -73,6 +73,63 @@ 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 . _isString ( 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 . _isString ( 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
+ this . _isStringOrBlock ( args [ 0 ] ) &&
106
+ this . _isNumberOrBlock ( args [ 1 ] ) &&
107
+ rubyBlockArgs && rubyBlockArgs . length === 0 &&
108
+ rubyBlock ) {
109
+ switch ( name ) {
110
+ case 'wedo2_when_tilted' :
111
+ if ( args . length === 1 && this . _isString ( args [ 0 ] ) ) {
112
+ block = this . _createBlock ( 'wedo2_whenTilted' , 'hat' ) ;
113
+ this . _addInput (
114
+ block ,
115
+ 'TILT_DIRECTION_ANY' ,
116
+ this . _createFieldBlock ( 'wedo2_menu_TILT_DIRECTION_ANY' , 'TILT_DIRECTION_ANY' , args [ 0 ] )
117
+ ) ;
118
+ this . _setParent ( rubyBlock , block ) ;
119
+ }
120
+ break ;
121
+ case 'wedo2_when_distance' :
122
+ if ( args . length === 2 && this . _isString ( args [ 0 ] ) && this . _isNumberOrBlock ( args [ 1 ] ) ) {
123
+ block = this . _createBlock ( 'wedo2_whenDistance' , 'hat' ) ;
124
+ this . _addInput (
125
+ block ,
126
+ 'OP' ,
127
+ this . _createFieldBlock ( 'wedo2_menu_OP' , 'OP' , args [ 0 ] )
128
+ ) ;
129
+ this . _addNumberInput ( block , 'REFERENCE' , 'math_number' , args [ 1 ] , 50 ) ;
130
+ this . _setParent ( rubyBlock , block ) ;
131
+ }
132
+ break ;
76
133
}
77
134
}
78
135
return block ;
0 commit comments