smalruby-editor 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/LEGAL +4 -3
- data/app/assets/javascripts/blocks/character.js.coffee.erb +7 -3
- data/app/assets/javascripts/blocks/events.js.coffee.erb +7 -10
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +119 -31
- data/app/assets/javascripts/blocks/motion.js.coffee.erb +16 -20
- data/app/assets/javascripts/blocks/operators.js.coffee.erb +1 -1
- data/app/assets/javascripts/blocks/pen.js.coffee.erb +2 -1
- data/app/assets/javascripts/blocks/ruby.js.coffee.erb +3 -3
- data/app/assets/javascripts/blocks/sensing.js.coffee.erb +8 -8
- data/app/assets/javascripts/blocks/sound.js.coffee.erb +3 -1
- data/app/assets/javascripts/fix_blockly.js.erb +105 -0
- data/app/assets/javascripts/generators/ruby.js.coffee.erb +3 -0
- data/app/assets/javascripts/msg/en_us.js +67 -17
- data/app/assets/javascripts/msg/ja.js +151 -95
- data/app/assets/javascripts/{smalruby.js.coffee → smalruby.js.coffee.erb} +35 -16
- data/app/assets/javascripts/views/character_selector_view.js.coffee +2 -2
- data/app/assets/javascripts/views/{load_modal_view.js.coffee → load_modal_view.js.coffee.erb} +8 -2
- data/app/assets/javascripts/views/main_menu_view.js.coffee.erb +33 -48
- data/app/assets/javascripts/views/signin_modal_view.js.coffee.erb +43 -0
- data/app/assets/stylesheets/application.css +3 -1
- data/app/assets/stylesheets/toolbox.css.scss.erb +2 -56
- data/app/assets/stylesheets/toolbox_default.css.scss.erb +34 -0
- data/app/assets/stylesheets/toolbox_smalrubot_s1.css.scss.erb +31 -0
- data/app/assets/stylesheets/toolbox_smalrubot_v3.css.scss.erb +32 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/source_codes_controller.rb +6 -3
- data/app/helpers/application_helper.rb +12 -0
- data/app/helpers/editor_helper.rb +25 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action.rb +13 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action_with_sec.rb +14 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_ir_photoreflector_value.rb +29 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_led_turn_on_or_off.rb +22 -0
- data/app/views/editor/_block_tab.html.haml +7 -6
- data/app/views/editor/_reset_modal.html.haml +4 -4
- data/app/views/editor/_signin_modal.html.haml +8 -9
- data/app/views/editor/_toolbox_default.html.haml +504 -0
- data/app/views/editor/_toolbox_smalrubot_s1.html.haml +171 -0
- data/app/views/editor/_toolbox_smalrubot_v3.html.haml +177 -0
- data/app/views/editor/index.html.haml +12 -2
- data/app/views/layouts/application.html.erb +1 -0
- data/config/environments/production.rb +1 -0
- data/config/locales/en.yml +19 -16
- data/config/locales/ja.yml +28 -25
- data/demos/hardware_led.rb.xml +79 -79
- data/lib/smalruby_editor.rb +58 -0
- data/lib/smalruby_editor/config.rb +22 -0
- data/lib/smalruby_editor/version.rb +1 -1
- data/public/blockly/media/anon.jpeg +0 -0
- data/public/blockly/media/handclosed.cur +0 -0
- data/public/blockly/media/handdelete.cur +0 -0
- data/public/blockly/media/progress.gif +0 -0
- data/public/blockly/media/sprites.png +0 -0
- data/smalruby-editor.gemspec +2 -1
- data/spec/acceptance/base.feature +3 -3
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action.feature +107 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action_with_sec.feature +151 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_ir_photoreflector_value.feature +100 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature +73 -0
- data/spec/acceptance/ruby_mode/translate.feature +6 -6
- data/spec/acceptance/standalone/save.feature +3 -3
- data/spec/acceptance/standalone/signin.feature +1 -2
- data/spec/lib/smalruby_editor_spec.rb +21 -11
- data/spec/models/concerns/ruby_to_block/block/hardware__smalrubot_s1_spec.rb +279 -0
- data/vendor/assets/javascripts/blockly/blockly_compressed.js +995 -668
- data/vendor/assets/javascripts/blockly/blocks_compressed.js +138 -114
- data/vendor/assets/javascripts/blockly/msg/js/en_us.js +6 -6
- data/vendor/assets/javascripts/blockly/msg/js/ja.js +42 -28
- metadata +66 -25
- data/app/assets/javascripts/fix_blockly.js +0 -128
- data/app/assets/javascripts/views/signin_modal_view.js.coffee +0 -33
- data/app/views/editor/_toolbox.html.haml +0 -496
- data/public/blockly/media/trashbody.png +0 -0
- data/public/blockly/media/trashlid.png +0 -0
- data/public/blockly/media/tree.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 010d3215efbb5df0cd39317ecfb6a2ce0070a83b
|
4
|
+
data.tar.gz: 5344949c05c898a44509e9e55facd2cdfcaa3c3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2c7f6ebbf7d2db584af2bef33d36fb0dfb5a35f2f3258b185afaab362c3829015fcf5c55ccc33f610f646db21860b64af40b74e8b1d0fd9bb176d8a2452faf9
|
7
|
+
data.tar.gz: 7f9c51dac3c909046814fa4e8acef7f8dfbc3519dca8192e71434adcefbef8e31bb50742e79944200ce45cf9a4dd869d7a1d81a06be1e61bea7b4b8f12bc0828
|
data/LEGAL
CHANGED
@@ -40,6 +40,7 @@ vendor/assets/javascripts/jquery.blockUI.js:
|
|
40
40
|
public/favicon.ico, public/apple-touch-icon.png, public/large.png,
|
41
41
|
public/square.png, public/tiny.png, public/wide.png:
|
42
42
|
|
43
|
-
Copyright (C) Hikari Arakawa (
|
44
|
-
|
45
|
-
|
43
|
+
Copyright (C) Hikari Arakawa (Ruby Programming Shounendan and
|
44
|
+
Smalruby) 2013. このイメージキャラクター、もしくはその派生版は、Ru
|
45
|
+
byプログラミング少年団とスモウルビー:Smalrubyに関連する文脈で誰で
|
46
|
+
も自由に利用できるが、それらは荒川ひかりによる保証を示すものではない。
|
@@ -19,10 +19,14 @@ Blockly.Blocks['<%= n %>'] =
|
|
19
19
|
nameField = new Blockly.FieldLabel('')
|
20
20
|
# HACK: ラベルをXMLとして出力させるためにEDITABLEをtrueにしている
|
21
21
|
nameField.EDITABLE = true
|
22
|
-
# HACK: 画像とラベルの縦位置を合わせる
|
23
|
-
nameField.textElement_.setAttribute('y', 10)
|
24
22
|
nameField.setText = _.bind(@nameFieldSetText_, @)
|
25
23
|
|
24
|
+
# HACK: 画像とラベルの縦位置を合わせる
|
25
|
+
originalInit = nameField.init
|
26
|
+
nameField.init = ->
|
27
|
+
originalInit.apply(@, arguments)
|
28
|
+
@getSvgRoot().setAttribute('y', size / 4)
|
29
|
+
|
26
30
|
@appendDummyInput()
|
27
31
|
.appendField(imageField, 'COSTUME')
|
28
32
|
.appendField(nameField, 'NAME')
|
@@ -34,7 +38,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
34
38
|
dispose: (healStack, animate) ->
|
35
39
|
@character.off 'change', @changeHandler
|
36
40
|
@character.unlink?(@)
|
37
|
-
|
41
|
+
@constructor.prototype.dispose.apply(@, arguments)
|
38
42
|
|
39
43
|
nameFieldSetText_: (name) ->
|
40
44
|
charSet = Smalruby.Collections.CharacterSet
|
@@ -32,12 +32,10 @@ Blockly.Blocks['<%= n %>'] =
|
|
32
32
|
|
33
33
|
@setHelpUrl('')
|
34
34
|
@setColour(<%= color %>)
|
35
|
-
@
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
.appendField(new Blockly.FieldDropdown(podDropdown), 'POD')
|
40
|
-
.appendField(<%= bm('.on_key_push_or_down_suffix') %>)
|
35
|
+
@interpolateMsg(<%= bm('.on_key_push_or_down') %>,
|
36
|
+
['KEY', new Blockly.FieldDropdown(keyDropdown)],
|
37
|
+
['POD', new Blockly.FieldDropdown(podDropdown)],
|
38
|
+
Blockly.ALIGN_RIGHT)
|
41
39
|
@appendStatementInput('DO')
|
42
40
|
@setPreviousStatement(true)
|
43
41
|
@setNextStatement(true)
|
@@ -70,10 +68,9 @@ Blockly.Blocks['<%= n %>'] =
|
|
70
68
|
init: ()->
|
71
69
|
@setHelpUrl('')
|
72
70
|
@setColour(<%= color %>)
|
73
|
-
@
|
74
|
-
|
75
|
-
|
76
|
-
.appendField(<%= bm('.on_hit_suffix') %>)
|
71
|
+
@interpolateMsg(<%= bm('.on_hit') %>,
|
72
|
+
['CHAR', new Smalruby.FieldCharacter()],
|
73
|
+
Blockly.ALIGN_RIGHT)
|
77
74
|
@appendStatementInput('DO')
|
78
75
|
@setPreviousStatement(true)
|
79
76
|
@setNextStatement(true)
|
@@ -83,7 +83,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
83
83
|
@setHelpUrl('')
|
84
84
|
@setColour(<%= colors[:looks] %>)
|
85
85
|
@interpolateMsg(<%= bm(".led_#{method}") %>,
|
86
|
-
['PIN',
|
86
|
+
['PIN', new Blockly.FieldDropdown(dioPinDropdown)],
|
87
87
|
Blockly.ALIGN_RIGHT)
|
88
88
|
@setPreviousStatement(true)
|
89
89
|
@setNextStatement(true)
|
@@ -105,9 +105,9 @@ Blockly.Blocks['<%= n %>'] =
|
|
105
105
|
@setHelpUrl('')
|
106
106
|
@setColour(<%= colors[:looks] %>)
|
107
107
|
@interpolateMsg(<%= bm('.rgb_led_set_color') %>,
|
108
|
-
['AC',
|
109
|
-
['PIN',
|
110
|
-
['COLOUR',
|
108
|
+
['AC', new Blockly.FieldDropdown(acDropdown)],
|
109
|
+
['PIN', new Blockly.FieldDropdown(rgbLedPinDropdown)],
|
110
|
+
['COLOUR', new Blockly.FieldColour('#ff0000')],
|
111
111
|
Blockly.ALIGN_RIGHT)
|
112
112
|
@setPreviousStatement(true)
|
113
113
|
@setNextStatement(true)
|
@@ -130,8 +130,8 @@ Blockly.Blocks['<%= n %>'] =
|
|
130
130
|
@setHelpUrl('')
|
131
131
|
@setColour(<%= colors[:looks] %>)
|
132
132
|
@interpolateMsg(<%= bm('.rgb_led_turn_off') %>,
|
133
|
-
['AC',
|
134
|
-
['PIN',
|
133
|
+
['AC', new Blockly.FieldDropdown(acDropdown)],
|
134
|
+
['PIN', new Blockly.FieldDropdown(rgbLedPinDropdown)],
|
135
135
|
Blockly.ALIGN_RIGHT)
|
136
136
|
@setPreviousStatement(true)
|
137
137
|
@setNextStatement(true)
|
@@ -153,7 +153,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
153
153
|
@setHelpUrl('')
|
154
154
|
@setColour(<%= colors[:looks] %>)
|
155
155
|
@interpolateMsg(<%= bm('.seven_segment_display_show') %>,
|
156
|
-
['NUM',
|
156
|
+
['NUM', new Blockly.FieldDropdown(dropdown)],
|
157
157
|
Blockly.ALIGN_RIGHT)
|
158
158
|
@setPreviousStatement(true)
|
159
159
|
@setNextStatement(true)
|
@@ -222,7 +222,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
222
222
|
@setHelpUrl('')
|
223
223
|
@setColour(<%= colors[:motion] %>)
|
224
224
|
@interpolateMsg(<%= bm('.servo_set_position') %>,
|
225
|
-
['PIN',
|
225
|
+
['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
|
226
226
|
['POS', ['Number'], Blockly.ALIGN_RIGHT],
|
227
227
|
Blockly.ALIGN_RIGHT)
|
228
228
|
@setInputsInline(true)
|
@@ -254,7 +254,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
254
254
|
@setHelpUrl('')
|
255
255
|
@setColour(<%= colors[:motion] %>)
|
256
256
|
@interpolateMsg(<%= bm(".#{subcategory}_#{method}") %>,
|
257
|
-
['PIN',
|
257
|
+
['PIN', new Blockly.FieldDropdown(twoWDPinDropdown)],
|
258
258
|
Blockly.ALIGN_RIGHT)
|
259
259
|
@setInputsInline(true)
|
260
260
|
@setPreviousStatement(true)
|
@@ -275,7 +275,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
275
275
|
@setColour(<%= colors[:motion] %>)
|
276
276
|
@interpolateMsg(<%= bm(".#{subcategory}_run") %>,
|
277
277
|
['COMMAND', ['String'], Blockly.ALIGN_RIGHT],
|
278
|
-
['PIN',
|
278
|
+
['PIN', new Blockly.FieldDropdown(twoWDPinDropdown)],
|
279
279
|
['SEC', ['Number'], Blockly.ALIGN_RIGHT],
|
280
280
|
Blockly.ALIGN_RIGHT)
|
281
281
|
@setInputsInline(true)
|
@@ -296,8 +296,9 @@ Blockly.Blocks['<%= n %>'] =
|
|
296
296
|
init: ()->
|
297
297
|
@setHelpUrl('')
|
298
298
|
@setColour(<%= colors[:motion] %>)
|
299
|
-
@
|
300
|
-
|
299
|
+
@interpolateMsg(<%= bm(".#{subcategory}_commands") %>,
|
300
|
+
['COMMAND', new Blockly.FieldDropdown(actionDropdown)],
|
301
|
+
Blockly.ALIGN_RIGHT)
|
301
302
|
@setOutput(true, 'String')
|
302
303
|
@setTooltip('')
|
303
304
|
|
@@ -312,8 +313,8 @@ Blockly.Blocks['<%= n %>'] =
|
|
312
313
|
@setHelpUrl('')
|
313
314
|
@setColour(<%= colors[:motion] %>)
|
314
315
|
@interpolateMsg(<%= bm(".#{subcategory}_set_speed") %>,
|
315
|
-
['PIN',
|
316
|
-
['LOR',
|
316
|
+
['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
|
317
|
+
['LOR', new Blockly.FieldDropdown(lorDropdown)],
|
317
318
|
['SPEED', ['Number'], Blockly.ALIGN_RIGHT],
|
318
319
|
Blockly.ALIGN_RIGHT)
|
319
320
|
@setInputsInline(true)
|
@@ -334,8 +335,8 @@ Blockly.Blocks['<%= n %>'] =
|
|
334
335
|
@setHelpUrl('')
|
335
336
|
@setColour(<%= colors[:sensing] %>)
|
336
337
|
@interpolateMsg(<%= bm(".#{subcategory}_speed") %>,
|
337
|
-
['PIN',
|
338
|
-
['LOR',
|
338
|
+
['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
|
339
|
+
['LOR', new Blockly.FieldDropdown(lorDropdown)],
|
339
340
|
Blockly.ALIGN_RIGHT)
|
340
341
|
@setOutput(true, 'Number')
|
341
342
|
@setTooltip('')
|
@@ -361,8 +362,8 @@ Blockly.Blocks['<%= n %>'] =
|
|
361
362
|
@setHelpUrl('')
|
362
363
|
@setColour(<%= colors[:motion] %>)
|
363
364
|
@interpolateMsg(<%= bm(".#{subcategory}") %>,
|
364
|
-
['PIN',
|
365
|
-
['METHOD',
|
365
|
+
['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
|
366
|
+
['METHOD', new Blockly.FieldDropdown(methodDropdown)],
|
366
367
|
Blockly.ALIGN_RIGHT)
|
367
368
|
@setInputsInline(true)
|
368
369
|
@setPreviousStatement(true)
|
@@ -382,7 +383,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
382
383
|
@setHelpUrl('')
|
383
384
|
@setColour(<%= colors[:motion] %>)
|
384
385
|
@interpolateMsg(<%= bm(".#{subcategory}_set_speed") %>,
|
385
|
-
['PIN',
|
386
|
+
['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
|
386
387
|
['SPEED', ['Number'], Blockly.ALIGN_RIGHT],
|
387
388
|
Blockly.ALIGN_RIGHT)
|
388
389
|
@setInputsInline(true)
|
@@ -402,7 +403,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
402
403
|
@setHelpUrl('')
|
403
404
|
@setColour(<%= colors[:sensing] %>)
|
404
405
|
@interpolateMsg(<%= bm(".#{subcategory}_speed") %>,
|
405
|
-
['PIN',
|
406
|
+
['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
|
406
407
|
Blockly.ALIGN_RIGHT)
|
407
408
|
@setOutput(true, 'Number')
|
408
409
|
@setTooltip('')
|
@@ -423,8 +424,8 @@ Blockly.Blocks['<%= n %>'] =
|
|
423
424
|
@setHelpUrl('')
|
424
425
|
@setColour(<%= colors[:sensing] %>)
|
425
426
|
@interpolateMsg(<%= bm(".button_pressed_or_released") %>,
|
426
|
-
['PIN',
|
427
|
-
['POR',
|
427
|
+
['PIN', new Blockly.FieldDropdown(dioPinDropdown)],
|
428
|
+
['POR', new Blockly.FieldDropdown(porDropdown)],
|
428
429
|
Blockly.ALIGN_RIGHT)
|
429
430
|
@setOutput(true, 'Boolean')
|
430
431
|
@setTooltip('')
|
@@ -443,7 +444,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
443
444
|
@setHelpUrl('')
|
444
445
|
@setColour(<%= colors[:sensing] %>)
|
445
446
|
@interpolateMsg(<%= bm('.sensor_value') %>,
|
446
|
-
['PIN',
|
447
|
+
['PIN', new Blockly.FieldDropdown(aiPinDropdown)],
|
447
448
|
Blockly.ALIGN_RIGHT)
|
448
449
|
@setOutput(true, 'Number')
|
449
450
|
@setTooltip('')
|
@@ -471,8 +472,8 @@ Blockly.Blocks['<%= n %>'] =
|
|
471
472
|
@setHelpUrl('')
|
472
473
|
@setColour(<%= colors[:looks] %>)
|
473
474
|
@interpolateMsg(<%= bm(".#{subcategory}_led_turn_on_or_off") %>,
|
474
|
-
['COLOUR',
|
475
|
-
['OOO',
|
475
|
+
['COLOUR', new Blockly.FieldDropdown(colourDropdown)],
|
476
|
+
['OOO', new Blockly.FieldDropdown(oooDropdown)],
|
476
477
|
Blockly.ALIGN_RIGHT)
|
477
478
|
@setInputsInline(true)
|
478
479
|
@setPreviousStatement(true)
|
@@ -491,7 +492,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
491
492
|
@setHelpUrl('')
|
492
493
|
@setColour(<%= colors[:sensing] %>)
|
493
494
|
@interpolateMsg(<%= bm(".#{subcategory}_motor_speed") %>,
|
494
|
-
['LOR',
|
495
|
+
['LOR', new Blockly.FieldDropdown(lorDropdown)],
|
495
496
|
Blockly.ALIGN_RIGHT)
|
496
497
|
@setOutput(true, 'Number')
|
497
498
|
@setTooltip('')
|
@@ -507,7 +508,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
507
508
|
@setHelpUrl('')
|
508
509
|
@setColour(<%= colors[:motion] %>)
|
509
510
|
@interpolateMsg(<%= bm(".#{subcategory}_motor_set_speed") %>,
|
510
|
-
['LOR',
|
511
|
+
['LOR', new Blockly.FieldDropdown(lorDropdown)],
|
511
512
|
['SPEED', ['Number'], Blockly.ALIGN_RIGHT],
|
512
513
|
Blockly.ALIGN_RIGHT)
|
513
514
|
@setInputsInline(true)
|
@@ -528,7 +529,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
528
529
|
@setHelpUrl('')
|
529
530
|
@setColour(<%= colors[:motion] %>)
|
530
531
|
@interpolateMsg(<%= bm(".#{subcategory}_action") %>,
|
531
|
-
['ACTION',
|
532
|
+
['ACTION', new Blockly.FieldDropdown(actionDropdown)],
|
532
533
|
Blockly.ALIGN_RIGHT)
|
533
534
|
@setInputsInline(true)
|
534
535
|
@setPreviousStatement(true)
|
@@ -546,7 +547,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
546
547
|
@setHelpUrl('')
|
547
548
|
@setColour(<%= colors[:motion] %>)
|
548
549
|
@interpolateMsg(<%= bm(".#{subcategory}_action_with_sec") %>,
|
549
|
-
['ACTION',
|
550
|
+
['ACTION', new Blockly.FieldDropdown(actionDropdown)],
|
550
551
|
['SEC', ['Number'], Blockly.ALIGN_RIGHT],
|
551
552
|
Blockly.ALIGN_RIGHT)
|
552
553
|
@setInputsInline(true)
|
@@ -568,8 +569,8 @@ Blockly.Blocks['<%= n %>'] =
|
|
568
569
|
@setHelpUrl('')
|
569
570
|
@setColour(<%= colors[:sensing] %>)
|
570
571
|
@interpolateMsg(<%= bm(".#{subcategory}_touch_sensor_pressed_or_released") %>,
|
571
|
-
['LOR',
|
572
|
-
['POR',
|
572
|
+
['LOR', new Blockly.FieldDropdown(lorDropdown)],
|
573
|
+
['POR', new Blockly.FieldDropdown(porDropdown)],
|
573
574
|
Blockly.ALIGN_RIGHT)
|
574
575
|
@setOutput(true, 'Boolean')
|
575
576
|
@setTooltip('')
|
@@ -591,3 +592,90 @@ Blockly.Blocks['<%= n %>'] =
|
|
591
592
|
|
592
593
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
593
594
|
Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.light_sensor.value")
|
595
|
+
|
596
|
+
|
597
|
+
# SmalrubotS1 sub category
|
598
|
+
<% subcategory = 'smalrubot_s1' %>
|
599
|
+
|
600
|
+
# turn on/off Smalrubot s1 blue/white LED
|
601
|
+
<% n = "#{category}_#{subcategory}_led_turn_on_or_off" %>
|
602
|
+
Blockly.Blocks['<%= n %>'] =
|
603
|
+
init: ()->
|
604
|
+
colourDropdown = [
|
605
|
+
[<%= bm('colour.blue') %>, 'blue'],
|
606
|
+
[<%= bm('colour.white') %>, 'white'],
|
607
|
+
]
|
608
|
+
oooDropdown = [
|
609
|
+
[<%= bm('common.turn_on') %>, 'turn_on'],
|
610
|
+
[<%= bm('common.turn_off') %>, 'turn_off'],
|
611
|
+
]
|
612
|
+
|
613
|
+
@setHelpUrl('')
|
614
|
+
@setColour(<%= colors[:looks] %>)
|
615
|
+
@interpolateMsg(<%= bm(".#{subcategory}_led_turn_on_or_off") %>,
|
616
|
+
['COLOUR', new Blockly.FieldDropdown(colourDropdown)],
|
617
|
+
['OOO', new Blockly.FieldDropdown(oooDropdown)],
|
618
|
+
Blockly.ALIGN_RIGHT)
|
619
|
+
@setInputsInline(true)
|
620
|
+
@setPreviousStatement(true)
|
621
|
+
@setNextStatement(true)
|
622
|
+
@setTooltip('')
|
623
|
+
|
624
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
625
|
+
colour = @getFieldValue('COLOUR')
|
626
|
+
ooo = @getFieldValue('OOO')
|
627
|
+
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{ooo}_#{colour}_led")
|
628
|
+
|
629
|
+
# forward/backward/turn left/turn right/stop Smalrubot s1
|
630
|
+
<% n = "#{category}_#{subcategory}_action" %>
|
631
|
+
Blockly.Blocks['<%= n %>'] =
|
632
|
+
init: ()->
|
633
|
+
@setHelpUrl('')
|
634
|
+
@setColour(<%= colors[:motion] %>)
|
635
|
+
@interpolateMsg(<%= bm(".#{subcategory}_action") %>,
|
636
|
+
['ACTION', new Blockly.FieldDropdown(actionDropdown)],
|
637
|
+
Blockly.ALIGN_RIGHT)
|
638
|
+
@setInputsInline(true)
|
639
|
+
@setPreviousStatement(true)
|
640
|
+
@setNextStatement(true)
|
641
|
+
@setTooltip('')
|
642
|
+
|
643
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
644
|
+
action = @getFieldValue('ACTION')
|
645
|
+
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{action}")
|
646
|
+
|
647
|
+
# forward/backward/turn left/turn right/stop Smalrubot s1 for ( ) secs
|
648
|
+
<% n = "#{category}_#{subcategory}_action_with_sec" %>
|
649
|
+
Blockly.Blocks['<%= n %>'] =
|
650
|
+
init: ()->
|
651
|
+
@setHelpUrl('')
|
652
|
+
@setColour(<%= colors[:motion] %>)
|
653
|
+
@interpolateMsg(<%= bm(".#{subcategory}_action_with_sec") %>,
|
654
|
+
['ACTION', new Blockly.FieldDropdown(actionDropdown)],
|
655
|
+
['SEC', ['Number'], Blockly.ALIGN_RIGHT],
|
656
|
+
Blockly.ALIGN_RIGHT)
|
657
|
+
@setInputsInline(true)
|
658
|
+
@setPreviousStatement(true)
|
659
|
+
@setNextStatement(true)
|
660
|
+
@setTooltip('')
|
661
|
+
|
662
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
663
|
+
action = @getFieldValue('ACTION')
|
664
|
+
sec = Blockly.Ruby.valueToCode(@, 'SEC', Blockly.Ruby.ORDER_FUNCTION_CALL) || 'nil'
|
665
|
+
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{action}(sec: #{sec})")
|
666
|
+
|
667
|
+
# Smalrubot s1 left/right ir photoreflector value
|
668
|
+
<% n = "#{category}_#{subcategory}_ir_photoreflector_value" %>
|
669
|
+
Blockly.Blocks['<%= n %>'] =
|
670
|
+
init: ()->
|
671
|
+
@setHelpUrl('')
|
672
|
+
@setColour(<%= colors[:sensing] %>)
|
673
|
+
@interpolateMsg(<%= bm(".#{subcategory}_ir_photoreflector_value") %>,
|
674
|
+
['LOR', new Blockly.FieldDropdown(lorDropdown)],
|
675
|
+
Blockly.ALIGN_RIGHT)
|
676
|
+
@setOutput(true, 'Boolean')
|
677
|
+
@setTooltip('')
|
678
|
+
|
679
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
680
|
+
lor = @getFieldValue('LOR')
|
681
|
+
Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.#{lor}_ir_photoreflector_value")
|
@@ -91,9 +91,9 @@ Blockly.Blocks['<%= n %>'] =
|
|
91
91
|
init: ()->
|
92
92
|
@setHelpUrl('')
|
93
93
|
@setColour(<%= color %>)
|
94
|
-
@
|
95
|
-
|
96
|
-
|
94
|
+
@interpolateMsg(<%= bm('.point_towards_character') %>,
|
95
|
+
['CHAR', new Smalruby.FieldCharacter()],
|
96
|
+
Blockly.ALIGN_RIGHT)
|
97
97
|
@setPreviousStatement(true)
|
98
98
|
@setNextStatement(true)
|
99
99
|
@setTooltip('')
|
@@ -108,11 +108,10 @@ Blockly.Blocks['<%= n %>'] =
|
|
108
108
|
init: ()->
|
109
109
|
@setHelpUrl('')
|
110
110
|
@setColour(<%= color %>)
|
111
|
-
@
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
@appendDummyInput().appendField(<%= bm('.set_x_y_suffix') %>)
|
111
|
+
@interpolateMsg(<%= bm('.set_x_y') %>,
|
112
|
+
['X', ['Number'], Blockly.ALIGN_RIGHT],
|
113
|
+
['Y', ['Number'], Blockly.ALIGN_RIGHT],
|
114
|
+
Blockly.ALIGN_RIGHT)
|
116
115
|
@setInputsInline(true)
|
117
116
|
@setPreviousStatement(true)
|
118
117
|
@setNextStatement(true)
|
@@ -144,10 +143,9 @@ Blockly.Blocks['<%= n %>'] =
|
|
144
143
|
init: ()->
|
145
144
|
@setHelpUrl('')
|
146
145
|
@setColour(<%= color %>)
|
147
|
-
@
|
148
|
-
|
149
|
-
|
150
|
-
.appendField(<%= bm('.go_to_character_suffix') %>)
|
146
|
+
@interpolateMsg(<%= bm('.go_to_character') %>,
|
147
|
+
['CHAR', new Smalruby.FieldCharacter()],
|
148
|
+
Blockly.ALIGN_RIGHT)
|
151
149
|
@setPreviousStatement(true)
|
152
150
|
@setNextStatement(true)
|
153
151
|
@setTooltip('')
|
@@ -248,10 +246,9 @@ Blockly.Blocks['<%= n %>'] =
|
|
248
246
|
|
249
247
|
@setHelpUrl('')
|
250
248
|
@setColour(<%= color %>)
|
251
|
-
@
|
252
|
-
|
253
|
-
|
254
|
-
.appendField(<%= bm('.turn_xy_suffix') %>)
|
249
|
+
@interpolateMsg(<%= bm('.turn_xy') %>,
|
250
|
+
['XY', new Blockly.FieldDropdown(dropdown)],
|
251
|
+
Blockly.ALIGN_RIGHT)
|
255
252
|
@setPreviousStatement(true)
|
256
253
|
@setNextStatement(true)
|
257
254
|
@setTooltip('')
|
@@ -272,10 +269,9 @@ Blockly.Blocks['<%= n %>'] =
|
|
272
269
|
|
273
270
|
@setHelpUrl('')
|
274
271
|
@setColour(<%= color %>)
|
275
|
-
@
|
276
|
-
|
277
|
-
|
278
|
-
.appendField(<%= bm('.set_rotation_style_suffix') %>)
|
272
|
+
@interpolateMsg(<%= bm('.set_rotation_style') %>,
|
273
|
+
['STYLE', new Blockly.FieldDropdown(dropdown)],
|
274
|
+
Blockly.ALIGN_RIGHT)
|
279
275
|
@setPreviousStatement(true)
|
280
276
|
@setNextStatement(true)
|
281
277
|
@setTooltip('')
|
@@ -241,7 +241,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
241
241
|
@setColour(<%= color %>)
|
242
242
|
@interpolateMsg(<%= bm('.math_method') %>,
|
243
243
|
['NUM', ['Number'], Blockly.ALIGN_RIGHT],
|
244
|
-
['METHOD',
|
244
|
+
['METHOD', new Blockly.FieldDropdown(dropdown)],
|
245
245
|
Blockly.ALIGN_RIGHT)
|
246
246
|
@setInputsInline(true)
|
247
247
|
@setOutput(true, 'Number')
|