rapid-router 5.4.1__py2.py3-none-any.whl → 7.6.8__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- example_project/rapid_router_test_settings.py +164 -0
- example_project/settings.py +152 -0
- example_project/urls.py +15 -0
- example_project/{example_project/wsgi.py → wsgi.py} +2 -1
- game/__init__.py +1 -1
- game/admin.py +43 -4
- game/app_settings.py +3 -7
- game/character.py +26 -18
- game/decor.py +172 -97
- game/end_to_end_tests/base_game_test.py +44 -33
- game/end_to_end_tests/editor_page.py +17 -2
- game/end_to_end_tests/game_page.py +127 -45
- game/end_to_end_tests/selenium_test_case.py +1 -20
- game/end_to_end_tests/test_cow_crashes.py +3 -5
- game/end_to_end_tests/test_language_dropdown.py +14 -0
- game/end_to_end_tests/test_level_editor.py +290 -0
- game/end_to_end_tests/test_level_failures.py +1 -1
- game/end_to_end_tests/test_level_selection.py +79 -0
- game/end_to_end_tests/test_play_through.py +240 -102
- game/end_to_end_tests/test_python_levels.py +44 -13
- game/end_to_end_tests/test_saving_workspace.py +22 -0
- game/forms.py +9 -2
- game/level_management.py +38 -29
- game/messages.py +1218 -203
- game/migrations/0001_squashed_0025_levels_ordering_pt1.py +19 -1
- game/migrations/0026_levels_pt2.py +13 -2
- game/migrations/0032_cannot_turn_left_level.py +13 -2
- game/migrations/0033_recursion_level.py +13 -2
- game/migrations/0034_joes_level.py +13 -2
- game/migrations/0035_disable_route_score_level_70.py +0 -2
- game/migrations/0036_level_score_73.py +0 -2
- game/migrations/0037_level_score_79.py +0 -2
- game/migrations/0038_level_score_40.py +0 -1
- game/migrations/0042_level_score_73.py +0 -2
- game/migrations/0048_add_cow_field_and_blocks.py +0 -2
- game/migrations/0049_level_score_34.py +0 -2
- game/migrations/0050_level_score_40.py +0 -2
- game/migrations/0051_level_score_49.py +0 -1
- game/migrations/0076_level_locked_for_class.py +19 -0
- game/migrations/0077_alter_level_next_level.py +52 -0
- game/migrations/0078_add_block_types.py +23 -0
- game/migrations/0079_populate_block_type_add_cow_blocks.py +60 -0
- game/migrations/0080_level_disable_algorithm_score.py +18 -0
- game/migrations/0081_first_12_levels_no_algo_score.py +29 -0
- game/migrations/0082_level_43_solution.py +16 -0
- game/migrations/0083_add_cows_to_existing_levels.py +195 -0
- game/migrations/0084_alter_block_block_type.py +18 -0
- game/migrations/0085_add_new_blocks.py +53 -0
- game/migrations/0086_loop_levels.py +482 -0
- game/migrations/0087_workspace_python_view_enabled.py +18 -0
- game/migrations/0088_rename_episodes.py +35 -0
- game/migrations/0089_episodes_in_development.py +30 -0
- game/migrations/0090_add_missing_model_solutions.py +144 -0
- game/migrations/0091_disable_algo_score_if_no_model_solution.py +46 -0
- game/migrations/0092_disable_algo_score_in_custom_levels.py +28 -0
- game/migrations/0093_alter_level_character_name.py +18 -0
- game/migrations/0094_add_hint_lesson_subtitle_to_levels.py +28 -0
- game/migrations/0095_level_commands.py +18 -0
- game/migrations/0096_alter_level_commands.py +18 -0
- game/migrations/0097_add_python_den_levels.py +1515 -0
- game/migrations/0098_add_episode_link_fields.py +44 -0
- game/migrations/0099_python_episodes_links.py +103 -0
- game/migrations/0100_reorder_python_levels.py +179 -0
- game/migrations/0101_rename_episodes.py +45 -0
- game/migrations/0102_reoder_episodes_13_14.py +136 -0
- game/migrations/0103_level_1015_solution.py +26 -0
- game/migrations/0104_remove_level_direct_drive.py +17 -0
- game/migrations/0105_delete_invalid_attempts.py +18 -0
- game/migrations/0106_fields_to_snake_case.py +48 -0
- game/migrations/0107_rename_worksheet_link_episode_student_worksheet_link.py +18 -0
- game/migrations/0108_episode_indy_worksheet_link.py +18 -0
- game/migrations/0109_create_episodes_23_and_24.py +99 -0
- game/migrations/0110_remove_episode_indy_worksheet_link_and_more.py +100 -0
- game/migrations/0111_create_worksheets.py +149 -0
- game/migrations/0112_worksheet_locked_classes.py +21 -0
- game/migrations/0113_level_needs_approval.py +18 -0
- game/migrations/0114_default_and_non_student_levels_no_approval.py +31 -0
- game/migrations/0115_level_level__default_does_not_need_approval.py +22 -0
- game/migrations/0116_update_worksheet_video_links.py +68 -0
- game/migrations/0117_update_solutions_to_if_else.py +61 -0
- game/models.py +157 -16
- game/permissions.py +34 -19
- game/python_den_urls.py +26 -0
- game/random_road.py +43 -127
- game/serializers.py +12 -17
- game/static/django_reverse_js/js/reverse.js +171 -0
- game/static/game/css/LilitaOne-Regular.ttf +0 -0
- game/static/game/css/backgrounds.css +14 -10
- game/static/game/css/dataTables.custom.css +4 -2
- game/static/game/css/dataTables.jqueryui.css +561 -320
- game/static/game/css/editor.css +47 -0
- game/static/game/css/game.css +43 -49
- game/static/game/css/game_screen.css +116 -53
- game/static/game/css/jquery.dataTables.css +455 -251
- game/static/game/css/level_editor.css +10 -1
- game/static/game/css/level_selection.css +32 -3
- game/static/game/css/level_share.css +6 -5
- game/static/game/css/skulpt/codemirror.css +1 -0
- game/static/game/image/Python_Den_hero_student.png +0 -0
- game/static/game/image/Python_levels_page.svg +1954 -0
- game/static/game/image/characters/front_view/Electric_van.svg +448 -0
- game/static/game/image/characters/top_view/Electric_van.svg +448 -0
- game/static/game/image/characters/top_view/Sleigh.svg +436 -0
- game/static/game/image/decor/city/solar_panel.svg +1200 -0
- game/static/game/image/decor/farm/solar_panel.svg +86 -0
- game/static/game/image/decor/grass/solar_panel.svg +86 -0
- game/static/game/image/decor/snow/barn.svg +1788 -0
- game/static/game/image/decor/snow/cfc.svg +1050 -147
- game/static/game/image/decor/snow/crops.svg +7370 -0
- game/static/game/image/decor/snow/hospital.svg +1220 -0
- game/static/game/image/decor/snow/house1.svg +971 -0
- game/static/game/image/decor/snow/house2.svg +1574 -0
- game/static/game/image/decor/snow/school.svg +1071 -0
- game/static/game/image/decor/snow/shop.svg +3211 -0
- game/static/game/image/decor/snow/solar_panel.svg +173 -0
- game/static/game/image/electric_van.svg +448 -0
- game/static/game/image/icons/add_house.svg +26 -0
- game/static/game/image/icons/delete_house.svg +26 -0
- game/static/game/image/icons/description.svg +1 -0
- game/static/game/image/icons/hint.svg +1 -0
- game/static/game/image/icons/if_else.svg +3 -0
- game/static/game/image/icons/python.svg +1 -1
- game/static/game/image/if_else_example.png +0 -0
- game/static/game/image/pigeon.svg +684 -0
- game/static/game/image/python_den_header.svg +19 -0
- game/static/game/js/animation.js +84 -28
- game/static/game/js/blockly/msg/js/bg.js +52 -1
- game/static/game/js/blockly/msg/js/ca.js +52 -1
- game/static/game/js/blockly/msg/js/en-gb.js +52 -1
- game/static/game/js/blockly/msg/js/en.js +52 -1
- game/static/game/js/blockly/msg/js/es.js +52 -1
- game/static/game/js/blockly/msg/js/fr.js +52 -1
- game/static/game/js/blockly/msg/js/hi.js +52 -1
- game/static/game/js/blockly/msg/js/it.js +52 -1
- game/static/game/js/blockly/msg/js/pl.js +52 -1
- game/static/game/js/blockly/msg/js/pt-br.js +52 -1
- game/static/game/js/blockly/msg/js/ru.js +52 -1
- game/static/game/js/blockly/msg/js/ur.js +52 -1
- game/static/game/js/blocklyCompiler.js +550 -392
- game/static/game/js/blocklyControl.js +335 -302
- game/static/game/js/blocklyCustomBlocks.js +691 -458
- game/static/game/js/blocklyCustomisations.js +3 -1
- game/static/game/js/button.js +12 -0
- game/static/game/js/cow.js +15 -130
- game/static/game/js/drawing.js +313 -201
- game/static/game/js/editor.js +23 -0
- game/static/game/js/game.js +148 -139
- game/static/game/js/jquery.dataTables.min.js +3 -159
- game/static/game/js/level_editor.js +823 -448
- game/static/game/js/level_moderation.js +33 -2
- game/static/game/js/level_selection.js +62 -25
- game/static/game/js/loadLanguages.js +21 -0
- game/static/game/js/map.js +106 -36
- game/static/game/js/model.js +55 -107
- game/static/game/js/pathFinder.js +73 -72
- game/static/game/js/program.js +184 -193
- game/static/game/js/pythonControl.js +14 -1
- game/static/game/js/scoreboard.js +0 -37
- game/static/game/js/scoreboardSharedLevels.js +48 -0
- game/static/game/js/sharing.js +22 -10
- game/static/game/js/skulpt/codemirror.js +5 -4
- game/static/game/js/skulpt/skulpt-stdlib.js +1 -1
- game/static/game/js/sound.js +52 -5
- game/static/game/js/van.js +0 -7
- game/static/game/raphael_image/characters/top_view/Electric_van.svg +448 -0
- game/static/game/raphael_image/characters/top_view/Sleigh.svg +436 -0
- game/static/game/raphael_image/decor/city/solar_panel.svg +1200 -0
- game/static/game/raphael_image/decor/farm/solar_panel.svg +86 -0
- game/static/game/raphael_image/decor/grass/solar_panel.svg +86 -0
- game/static/game/raphael_image/decor/snow/barn.svg +1788 -0
- game/static/game/raphael_image/decor/snow/cfc.svg +1050 -147
- game/static/game/raphael_image/decor/snow/crops.svg +7370 -0
- game/static/game/raphael_image/decor/snow/hospital.svg +1220 -0
- game/static/game/raphael_image/decor/snow/house1.svg +971 -0
- game/static/game/raphael_image/decor/snow/house2.svg +1574 -0
- game/static/game/raphael_image/decor/snow/school.svg +1071 -0
- game/static/game/raphael_image/decor/snow/shop.svg +3211 -0
- game/static/game/raphael_image/decor/snow/solar_panel.svg +173 -0
- game/static/game/raphael_image/pigeon.svg +685 -0
- game/static/game/raphael_image/sleigh_wreckage.svg +430 -0
- game/static/game/sass/game.scss +22 -6
- game/static/game/sound/clown_horn.mp3 +0 -0
- game/static/game/sound/clown_horn.ogg +0 -0
- game/static/game/sound/electric_van_starting.mp3 +0 -0
- game/static/game/sound/electric_van_starting.ogg +0 -0
- game/static/game/sound/pigeon.mp3 +0 -0
- game/static/game/sound/pigeon.ogg +0 -0
- game/static/game/sound/sleigh_bells.mp3 +0 -0
- game/static/game/sound/sleigh_bells.ogg +0 -0
- game/static/game/sound/sleigh_crash.mp3 +0 -0
- game/static/game/sound/sleigh_crash.ogg +0 -0
- game/templates/game/base.html +35 -15
- game/templates/game/basenonav.html +23 -17
- game/templates/game/game.html +236 -111
- game/templates/game/level_editor.html +353 -275
- game/templates/game/level_moderation.html +19 -6
- game/templates/game/level_selection.html +75 -62
- game/templates/game/python_den_level_selection.html +291 -0
- game/templates/game/python_den_worksheet.html +101 -0
- game/templates/game/scoreboard.html +88 -65
- game/tests/test_level_editor.py +210 -35
- game/tests/test_level_moderation.py +6 -20
- game/tests/test_level_selection.py +332 -11
- game/tests/test_python_den_worksheet.py +85 -0
- game/tests/test_scoreboard.py +258 -66
- game/tests/utils/level.py +43 -3
- game/tests/utils/teacher.py +2 -2
- game/theme.py +21 -21
- game/urls.py +125 -78
- game/views/language_code_conversions.py +90 -0
- game/views/level.py +201 -63
- game/views/level_editor.py +109 -48
- game/views/level_moderation.py +29 -6
- game/views/level_selection.py +179 -56
- game/views/level_solutions.py +600 -106
- game/views/scoreboard.py +181 -66
- game/views/worksheet.py +25 -0
- rapid_router-7.6.8.dist-info/METADATA +174 -0
- {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/RECORD +222 -242
- {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/WHEEL +1 -1
- rapid_router-7.6.8.dist-info/licenses/LICENSE.md +3 -0
- example_project/example_project/__init__.py +0 -1
- example_project/example_project/settings.py +0 -54
- example_project/example_project/urls.py +0 -16
- example_project/manage.py +0 -10
- game/autoconfig.py +0 -59
- game/csp_config.py +0 -23
- game/locale/ar_SA/LC_MESSAGES/django.mo +0 -0
- game/locale/ar_SA/LC_MESSAGES/django.po +0 -405
- game/locale/ar_SA/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ar_SA/LC_MESSAGES/djangojs.po +0 -743
- game/locale/bg_BG/LC_MESSAGES/django.mo +0 -0
- game/locale/bg_BG/LC_MESSAGES/django.po +0 -405
- game/locale/bg_BG/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/bg_BG/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ca_ES/LC_MESSAGES/django.mo +0 -0
- game/locale/ca_ES/LC_MESSAGES/django.po +0 -405
- game/locale/ca_ES/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ca_ES/LC_MESSAGES/djangojs.po +0 -740
- game/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
- game/locale/cs_CZ/LC_MESSAGES/django.po +0 -405
- game/locale/cs_CZ/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/cs_CZ/LC_MESSAGES/djangojs.po +0 -741
- game/locale/cy_GB/LC_MESSAGES/django.mo +0 -0
- game/locale/cy_GB/LC_MESSAGES/django.po +0 -405
- game/locale/cy_GB/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/cy_GB/LC_MESSAGES/djangojs.po +0 -743
- game/locale/de_DE/LC_MESSAGES/django.mo +0 -0
- game/locale/de_DE/LC_MESSAGES/django.po +0 -405
- game/locale/de_DE/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/de_DE/LC_MESSAGES/djangojs.po +0 -739
- game/locale/el_GR/LC_MESSAGES/django.mo +0 -0
- game/locale/el_GR/LC_MESSAGES/django.po +0 -405
- game/locale/el_GR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/el_GR/LC_MESSAGES/djangojs.po +0 -739
- game/locale/en_GB/LC_MESSAGES/django.mo +0 -0
- game/locale/en_GB/LC_MESSAGES/django.po +0 -405
- game/locale/en_GB/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/en_GB/LC_MESSAGES/djangojs.po +0 -739
- game/locale/es_ES/LC_MESSAGES/django.mo +0 -0
- game/locale/es_ES/LC_MESSAGES/django.po +0 -405
- game/locale/es_ES/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/es_ES/LC_MESSAGES/djangojs.po +0 -739
- game/locale/fi_FI/LC_MESSAGES/django.mo +0 -0
- game/locale/fi_FI/LC_MESSAGES/django.po +0 -405
- game/locale/fi_FI/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/fi_FI/LC_MESSAGES/djangojs.po +0 -739
- game/locale/fr_FR/LC_MESSAGES/django.mo +0 -0
- game/locale/fr_FR/LC_MESSAGES/django.po +0 -405
- game/locale/fr_FR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/fr_FR/LC_MESSAGES/djangojs.po +0 -739
- game/locale/gu_IN/LC_MESSAGES/django.mo +0 -0
- game/locale/gu_IN/LC_MESSAGES/django.po +0 -405
- game/locale/gu_IN/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/gu_IN/LC_MESSAGES/djangojs.po +0 -739
- game/locale/hi_IN/LC_MESSAGES/django.mo +0 -0
- game/locale/hi_IN/LC_MESSAGES/django.po +0 -405
- game/locale/hi_IN/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/hi_IN/LC_MESSAGES/djangojs.po +0 -739
- game/locale/id_ID/LC_MESSAGES/django.mo +0 -0
- game/locale/id_ID/LC_MESSAGES/django.po +0 -405
- game/locale/id_ID/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/id_ID/LC_MESSAGES/djangojs.po +0 -738
- game/locale/it_IT/LC_MESSAGES/django.mo +0 -0
- game/locale/it_IT/LC_MESSAGES/django.po +0 -405
- game/locale/it_IT/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/it_IT/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ja_JP/LC_MESSAGES/django.mo +0 -0
- game/locale/ja_JP/LC_MESSAGES/django.po +0 -405
- game/locale/ja_JP/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ja_JP/LC_MESSAGES/djangojs.po +0 -738
- game/locale/lol_US/LC_MESSAGES/django.mo +0 -0
- game/locale/lol_US/LC_MESSAGES/django.po +0 -405
- game/locale/lol_US/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/lol_US/LC_MESSAGES/djangojs.po +0 -739
- game/locale/nb_NO/LC_MESSAGES/django.mo +0 -0
- game/locale/nb_NO/LC_MESSAGES/django.po +0 -405
- game/locale/nb_NO/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/nb_NO/LC_MESSAGES/djangojs.po +0 -739
- game/locale/nl_NL/LC_MESSAGES/django.mo +0 -0
- game/locale/nl_NL/LC_MESSAGES/django.po +0 -405
- game/locale/nl_NL/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/nl_NL/LC_MESSAGES/djangojs.po +0 -739
- game/locale/pl_PL/LC_MESSAGES/django.mo +0 -0
- game/locale/pl_PL/LC_MESSAGES/django.po +0 -405
- game/locale/pl_PL/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/pl_PL/LC_MESSAGES/djangojs.po +0 -741
- game/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
- game/locale/pt_BR/LC_MESSAGES/django.po +0 -405
- game/locale/pt_BR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/pt_BR/LC_MESSAGES/djangojs.po +0 -739
- game/locale/pt_PT/LC_MESSAGES/django.mo +0 -0
- game/locale/pt_PT/LC_MESSAGES/django.po +0 -405
- game/locale/pt_PT/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/pt_PT/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ro_RO/LC_MESSAGES/django.mo +0 -0
- game/locale/ro_RO/LC_MESSAGES/django.po +0 -405
- game/locale/ro_RO/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ro_RO/LC_MESSAGES/djangojs.po +0 -740
- game/locale/ru_RU/LC_MESSAGES/django.mo +0 -0
- game/locale/ru_RU/LC_MESSAGES/django.po +0 -405
- game/locale/ru_RU/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ru_RU/LC_MESSAGES/djangojs.po +0 -741
- game/locale/sv_SE/LC_MESSAGES/django.mo +0 -0
- game/locale/sv_SE/LC_MESSAGES/django.po +0 -405
- game/locale/sv_SE/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/sv_SE/LC_MESSAGES/djangojs.po +0 -739
- game/locale/tl_PH/LC_MESSAGES/django.mo +0 -0
- game/locale/tl_PH/LC_MESSAGES/django.po +0 -405
- game/locale/tl_PH/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/tl_PH/LC_MESSAGES/djangojs.po +0 -739
- game/locale/tlh_AA/LC_MESSAGES/django.mo +0 -0
- game/locale/tlh_AA/LC_MESSAGES/django.po +0 -405
- game/locale/tlh_AA/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/tlh_AA/LC_MESSAGES/djangojs.po +0 -739
- game/locale/tr_TR/LC_MESSAGES/django.mo +0 -0
- game/locale/tr_TR/LC_MESSAGES/django.po +0 -405
- game/locale/tr_TR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/tr_TR/LC_MESSAGES/djangojs.po +0 -740
- game/locale/ur_IN/LC_MESSAGES/django.mo +0 -0
- game/locale/ur_IN/LC_MESSAGES/django.po +0 -405
- game/locale/ur_IN/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ur_IN/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ur_PK/LC_MESSAGES/django.mo +0 -0
- game/locale/ur_PK/LC_MESSAGES/django.po +0 -405
- game/locale/ur_PK/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ur_PK/LC_MESSAGES/djangojs.po +0 -739
- game/static/game/image/actions/go.svg +0 -18
- game/static/game/image/icons/destination.svg +0 -9
- game/static/game/js/pqselect.min.js +0 -9
- game/static/game/js/widget-scroller.js +0 -906
- rapid_router-5.4.1.dist-info/LICENSE.md +0 -577
- rapid_router-5.4.1.dist-info/METADATA +0 -24
- {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/top_level.txt +0 -0
|
@@ -1,471 +1,704 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
var ocargo = ocargo || {};
|
|
4
4
|
var Blockly = Blockly || {};
|
|
5
5
|
|
|
6
6
|
function initCustomBlocks() {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
initCustomBlocksDescription();
|
|
8
|
+
initCustomBlocksPython();
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function initCustomBlocksDescription() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
12
|
+
Blockly.Blocks["start"] = {
|
|
13
|
+
// Beginning block - identifies the start of the program
|
|
14
|
+
init: function () {
|
|
15
|
+
ocargo.blocklyControl.numStartBlocks++;
|
|
16
|
+
this.setColour(50);
|
|
17
|
+
this.appendDummyInput()
|
|
18
|
+
.appendField(Blockly.Msg.START_TITLE)
|
|
19
|
+
.appendField(
|
|
20
|
+
new Blockly.FieldImage(
|
|
21
|
+
new Date().getMonth() === 11 && CHARACTER_NAME === "Van"
|
|
22
|
+
? ocargo.Drawing.imageDir + "characters/top_view/Sleigh.svg"
|
|
23
|
+
: ocargo.Drawing.imageDir + CHARACTER_EN_FACE_URL,
|
|
24
|
+
ocargo.BlocklyControl.BLOCK_CHARACTER_HEIGHT,
|
|
25
|
+
ocargo.BlocklyControl.BLOCK_CHARACTER_WIDTH
|
|
26
|
+
)
|
|
27
|
+
);
|
|
28
|
+
this.setNextStatement(true, "Action");
|
|
29
|
+
this.setTooltip(Blockly.Msg.START_TOOLTIP);
|
|
30
|
+
this.setDeletable(false);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/*****************/
|
|
35
|
+
/* Action Blocks */
|
|
36
|
+
/*****************/
|
|
37
|
+
|
|
38
|
+
Blockly.Blocks["move_forwards"] = {
|
|
39
|
+
// Block for moving forward
|
|
40
|
+
init: function () {
|
|
41
|
+
this.setColour(160);
|
|
42
|
+
this.appendDummyInput()
|
|
43
|
+
.appendField(Blockly.Msg.MOVE_FORWARDS_TITLE)
|
|
44
|
+
.appendField(
|
|
45
|
+
new Blockly.FieldImage(
|
|
46
|
+
ocargo.Drawing.imageDir + "actions/forward.svg",
|
|
47
|
+
ocargo.BlocklyControl.IMAGE_WIDTH,
|
|
48
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
this.setPreviousStatement(true, "Action");
|
|
52
|
+
this.setNextStatement(true, "Action");
|
|
53
|
+
this.setTooltip(Blockly.Msg.MOVE_FORWARDS_TOOLTIP);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
Blockly.Blocks["turn_left"] = {
|
|
58
|
+
// Block for turning left
|
|
59
|
+
init: function () {
|
|
60
|
+
this.setColour(160);
|
|
61
|
+
this.appendDummyInput()
|
|
62
|
+
.appendField(Blockly.Msg.TURN_LEFT_TITLE)
|
|
63
|
+
.appendField(
|
|
64
|
+
new Blockly.FieldImage(
|
|
65
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
66
|
+
38,
|
|
67
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
.appendField(
|
|
71
|
+
new Blockly.FieldImage(
|
|
72
|
+
ocargo.Drawing.imageDir + "actions/left.svg",
|
|
73
|
+
ocargo.BlocklyControl.IMAGE_WIDTH,
|
|
74
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
this.setPreviousStatement(true, "Action");
|
|
78
|
+
this.setNextStatement(true, "Action");
|
|
79
|
+
this.setTooltip(Blockly.Msg.TURN_LEFT_TOOLTIP);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
Blockly.Blocks["turn_right"] = {
|
|
84
|
+
// Block for turning right
|
|
85
|
+
init: function () {
|
|
86
|
+
this.setColour(160);
|
|
87
|
+
this.appendDummyInput()
|
|
88
|
+
.appendField(Blockly.Msg.TURN_RIGHT_TITLE)
|
|
89
|
+
.appendField(
|
|
90
|
+
new Blockly.FieldImage(
|
|
91
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
92
|
+
29,
|
|
93
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
.appendField(
|
|
97
|
+
new Blockly.FieldImage(
|
|
98
|
+
ocargo.Drawing.imageDir + "actions/right.svg",
|
|
99
|
+
ocargo.BlocklyControl.IMAGE_WIDTH,
|
|
100
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
this.setPreviousStatement(true, "Action");
|
|
104
|
+
this.setNextStatement(true, "Action");
|
|
105
|
+
this.setTooltip(Blockly.Msg.TURN_RIGHT_TOOLTIP);
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
Blockly.Blocks["turn_around"] = {
|
|
110
|
+
// Block for turning around
|
|
111
|
+
init: function () {
|
|
112
|
+
this.setColour(160);
|
|
113
|
+
this.appendDummyInput()
|
|
114
|
+
.appendField(Blockly.Msg.TURN_AROUND_TITLE)
|
|
115
|
+
.appendField(
|
|
116
|
+
new Blockly.FieldImage(
|
|
117
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
118
|
+
12,
|
|
119
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
120
|
+
)
|
|
121
|
+
)
|
|
122
|
+
.appendField(
|
|
123
|
+
new Blockly.FieldImage(
|
|
124
|
+
ocargo.Drawing.imageDir + "actions/turn_around.svg",
|
|
125
|
+
ocargo.BlocklyControl.IMAGE_WIDTH,
|
|
126
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
127
|
+
)
|
|
128
|
+
);
|
|
129
|
+
this.setPreviousStatement(true, "Action");
|
|
130
|
+
this.setNextStatement(true, "Action");
|
|
131
|
+
this.setTooltip(Blockly.Msg.TURN_AROUND_TOOLTIP);
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
Blockly.Blocks["wait"] = {
|
|
136
|
+
// Block for not moving the van for a time
|
|
137
|
+
init: function () {
|
|
138
|
+
this.setColour(160);
|
|
139
|
+
this.appendDummyInput()
|
|
140
|
+
.appendField(Blockly.Msg.WAIT_TITLE)
|
|
141
|
+
.appendField(
|
|
142
|
+
new Blockly.FieldImage(
|
|
143
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
144
|
+
60,
|
|
145
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
146
|
+
)
|
|
147
|
+
)
|
|
148
|
+
.appendField(
|
|
149
|
+
new Blockly.FieldImage(
|
|
150
|
+
ocargo.Drawing.imageDir + "actions/wait.svg",
|
|
151
|
+
ocargo.BlocklyControl.IMAGE_WIDTH,
|
|
152
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
153
|
+
)
|
|
154
|
+
);
|
|
155
|
+
this.setPreviousStatement(true, "Action");
|
|
156
|
+
this.setNextStatement(true, "Action");
|
|
157
|
+
this.setTooltip(Blockly.Msg.WAIT_TOOLTIP);
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
Blockly.Blocks["deliver"] = {
|
|
162
|
+
// Block for delivering (only on levels with multiple destinations)
|
|
163
|
+
init: function () {
|
|
164
|
+
this.setColour(160);
|
|
165
|
+
this.appendDummyInput()
|
|
166
|
+
.appendField(Blockly.Msg.DELIVER_TITLE)
|
|
167
|
+
.appendField(
|
|
168
|
+
new Blockly.FieldImage(
|
|
169
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
170
|
+
43,
|
|
171
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
172
|
+
)
|
|
173
|
+
)
|
|
174
|
+
.appendField(
|
|
175
|
+
new Blockly.FieldImage(
|
|
176
|
+
ocargo.Drawing.imageDir + "actions/deliver.svg",
|
|
177
|
+
ocargo.BlocklyControl.IMAGE_WIDTH,
|
|
178
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
179
|
+
)
|
|
180
|
+
);
|
|
181
|
+
this.setPreviousStatement(true, "Action");
|
|
182
|
+
this.setNextStatement(true, "Action");
|
|
183
|
+
this.setTooltip(Blockly.Msg.DELIVER_TOOLTIP);
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
Blockly.Blocks["sound_horn"] = {
|
|
188
|
+
init: function () {
|
|
189
|
+
this.setColour(160);
|
|
190
|
+
this.appendDummyInput()
|
|
191
|
+
.appendField(Blockly.Msg.SOUND_HORN_TITLE)
|
|
192
|
+
.appendField(
|
|
193
|
+
new Blockly.FieldImage(
|
|
194
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
195
|
+
43,
|
|
196
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
197
|
+
)
|
|
198
|
+
)
|
|
199
|
+
.appendField(
|
|
200
|
+
new Blockly.FieldImage(
|
|
201
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
202
|
+
ocargo.BlocklyControl.IMAGE_WIDTH,
|
|
203
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
204
|
+
)
|
|
205
|
+
);
|
|
206
|
+
this.setPreviousStatement(true, "Action");
|
|
207
|
+
this.setNextStatement(true, "Action");
|
|
208
|
+
this.setTooltip(Blockly.Msg.SOUND_HORN_TOOLTIP);
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/*****************/
|
|
213
|
+
/* Conditions */
|
|
214
|
+
/*****************/
|
|
215
|
+
|
|
216
|
+
Blockly.Blocks["road_exists"] = {
|
|
217
|
+
init: function () {
|
|
218
|
+
var BOOLEANS = [
|
|
219
|
+
[Blockly.Msg.ROAD_EXISTS_FORWARD_TITLE, "FORWARD"],
|
|
220
|
+
[Blockly.Msg.ROAD_EXISTS_LEFT_TITLE, "LEFT"],
|
|
221
|
+
[Blockly.Msg.ROAD_EXISTS_RIGHT_TITLE, "RIGHT"],
|
|
222
|
+
];
|
|
223
|
+
this.setColour(210);
|
|
224
|
+
this.setOutput(true, "Boolean");
|
|
225
|
+
this.appendDummyInput()
|
|
226
|
+
.appendField(new Blockly.FieldDropdown(BOOLEANS), "CHOICE")
|
|
227
|
+
.appendField(
|
|
228
|
+
new Blockly.FieldImage(
|
|
229
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
230
|
+
ocargo.BlocklyControl.EXTRA_BLOCK_WIDTH,
|
|
231
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
232
|
+
)
|
|
233
|
+
);
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
Blockly.Blocks["traffic_light"] = {
|
|
238
|
+
init: function () {
|
|
239
|
+
var BOOLEANS = [
|
|
240
|
+
[Blockly.Msg.TRAFFIC_LIGHT_RED_TITLE, ocargo.TrafficLight.RED],
|
|
241
|
+
[Blockly.Msg.TRAFFIC_LIGHT_GREEN_TITLE, ocargo.TrafficLight.GREEN],
|
|
242
|
+
];
|
|
243
|
+
this.setColour(210);
|
|
244
|
+
this.setOutput(true, "Boolean");
|
|
245
|
+
this.appendDummyInput()
|
|
246
|
+
.appendField(new Blockly.FieldDropdown(BOOLEANS), "CHOICE")
|
|
247
|
+
.appendField(
|
|
248
|
+
new Blockly.FieldImage(
|
|
249
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
250
|
+
ocargo.BlocklyControl.EXTRA_BLOCK_WIDTH,
|
|
251
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
252
|
+
)
|
|
253
|
+
);
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
Blockly.Blocks["dead_end"] = {
|
|
258
|
+
init: function () {
|
|
259
|
+
this.setColour(210);
|
|
260
|
+
this.setOutput(true, "Boolean");
|
|
261
|
+
this.appendDummyInput()
|
|
262
|
+
.appendField(Blockly.Msg.DEAD_END_TITLE)
|
|
263
|
+
.appendField(
|
|
264
|
+
new Blockly.FieldImage(
|
|
265
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
266
|
+
ocargo.BlocklyControl.EXTRA_BLOCK_WIDTH,
|
|
267
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
268
|
+
)
|
|
269
|
+
);
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
Blockly.Blocks["at_destination"] = {
|
|
274
|
+
init: function () {
|
|
275
|
+
this.setColour(210);
|
|
276
|
+
this.setOutput(true, "Boolean");
|
|
277
|
+
this.appendDummyInput()
|
|
278
|
+
.appendField(Blockly.Msg.AT_DESTINATION_TITLE)
|
|
279
|
+
.appendField(
|
|
280
|
+
new Blockly.FieldImage(
|
|
281
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
282
|
+
ocargo.BlocklyControl.EXTRA_BLOCK_WIDTH,
|
|
283
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
284
|
+
)
|
|
285
|
+
);
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
Blockly.Blocks["cow_crossing"] = {
|
|
290
|
+
init: function () {
|
|
291
|
+
this.setColour(210);
|
|
292
|
+
this.setOutput(true, "Boolean");
|
|
293
|
+
let imageUrl =
|
|
294
|
+
ocargo.Drawing.animalType == ocargo.Cow.PIGEON
|
|
295
|
+
? ocargo.Drawing.pigeonUrl
|
|
296
|
+
: ocargo.Drawing.whiteCowUrl;
|
|
297
|
+
this.appendDummyInput()
|
|
298
|
+
.appendField(
|
|
299
|
+
ocargo.Drawing.animalType == ocargo.Cow.PIGEON
|
|
300
|
+
? Blockly.Msg.PIGEON_CROSSING_TITLE
|
|
301
|
+
: Blockly.Msg.COW_CROSSING_TITLE
|
|
302
|
+
)
|
|
303
|
+
.appendField(
|
|
304
|
+
new Blockly.FieldImage(
|
|
305
|
+
ocargo.Drawing.imageDir + imageUrl,
|
|
306
|
+
ocargo.BlocklyControl.COW_WIDTH,
|
|
307
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
308
|
+
),
|
|
309
|
+
"IMAGE"
|
|
310
|
+
);
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
Blockly.Blocks["pigeon_crossing_IMAGE_ONLY"] = {
|
|
315
|
+
init: function () {
|
|
316
|
+
this.setColour(210);
|
|
317
|
+
this.setOutput(true, "Boolean");
|
|
318
|
+
this.appendDummyInput()
|
|
319
|
+
.appendField("pigeons")
|
|
320
|
+
.appendField(
|
|
321
|
+
new Blockly.FieldImage(
|
|
322
|
+
ocargo.Drawing.imageDir + ocargo.Drawing.pigeonUrl,
|
|
323
|
+
ocargo.BlocklyControl.COW_WIDTH,
|
|
324
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
325
|
+
),
|
|
326
|
+
"IMAGE"
|
|
327
|
+
);
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
/****************/
|
|
331
|
+
/* Procedures */
|
|
332
|
+
/****************/
|
|
333
|
+
|
|
334
|
+
Blockly.Blocks["call_proc"] = {
|
|
335
|
+
// Block for calling a defined procedure
|
|
336
|
+
init: function () {
|
|
337
|
+
var name = "";
|
|
338
|
+
this.setColour(260);
|
|
339
|
+
this.appendDummyInput()
|
|
340
|
+
.appendField(Blockly.Msg.CALL_PROC_TITLE)
|
|
341
|
+
.appendField(
|
|
342
|
+
new Blockly.FieldImage(
|
|
343
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
344
|
+
7,
|
|
345
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
346
|
+
)
|
|
347
|
+
)
|
|
348
|
+
.appendField(new Blockly.FieldTextInput(name), "NAME");
|
|
349
|
+
this.setPreviousStatement(true, "Action");
|
|
350
|
+
this.setNextStatement(true, "Action");
|
|
351
|
+
this.setTooltip(Blockly.Msg.CALL_PROC_TOOLTIP);
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
Blockly.Blocks["declare_proc"] = {
|
|
356
|
+
// Block for declaring a procedure
|
|
357
|
+
init: function () {
|
|
358
|
+
var name = "";
|
|
359
|
+
this.setColour(260);
|
|
360
|
+
this.appendDummyInput()
|
|
361
|
+
.appendField(Blockly.Msg.DECLARE_PROC_TITLE)
|
|
362
|
+
.appendField(new Blockly.FieldTextInput(name), "NAME");
|
|
363
|
+
this.appendStatementInput("DO")
|
|
364
|
+
.setCheck("Action")
|
|
365
|
+
.appendField(Blockly.Msg.DECLARE_PROC_SUBTITLE);
|
|
366
|
+
this.setTooltip(Blockly.Msg.DECLARE_PROC_TOOLTIP);
|
|
367
|
+
this.statementConnection_ = null;
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
/****************/
|
|
372
|
+
/* Events */
|
|
373
|
+
/****************/
|
|
374
|
+
|
|
375
|
+
Blockly.Blocks["declare_event"] = {
|
|
376
|
+
// Block for declaring an event handler
|
|
377
|
+
init: function () {
|
|
378
|
+
this.setColour(260);
|
|
379
|
+
var dropdown = new Blockly.FieldDropdown(
|
|
380
|
+
[
|
|
381
|
+
[gettext("white"), ocargo.Cow.WHITE],
|
|
382
|
+
[gettext("brown"), ocargo.Cow.BROWN],
|
|
383
|
+
],
|
|
384
|
+
function (option) {
|
|
385
|
+
var imageUrl =
|
|
386
|
+
ocargo.Drawing.imageDir + ocargo.Drawing.cowUrl(option);
|
|
387
|
+
this.sourceBlock_.getField("IMAGE").setValue(imageUrl);
|
|
172
388
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
var originalInit = controlsRepeatBlock.init;
|
|
346
|
-
controlsRepeatBlock.init = function () {
|
|
347
|
-
originalInit.call(this);
|
|
348
|
-
|
|
349
|
-
this.setPreviousStatement(!0, 'Action');
|
|
350
|
-
this.setNextStatement(!0, 'Action');
|
|
351
|
-
this.inputList[1].setCheck('Action'); //Disallow event action blocks to be in body
|
|
352
|
-
|
|
353
|
-
var input = this.inputList[0];
|
|
354
|
-
var field = input.fieldRow[1];
|
|
355
|
-
field.changeHandler_ = function(text) {
|
|
356
|
-
var n = Blockly.FieldTextInput.numberValidator(text);
|
|
357
|
-
if (n) {
|
|
358
|
-
n = String(Math.min(Math.max(0, Math.floor(n)), 20));
|
|
359
|
-
}
|
|
360
|
-
return n;
|
|
361
|
-
};
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
// Make 'not' taller
|
|
365
|
-
var notBlock = Blockly.Blocks['logic_negate'];
|
|
366
|
-
var originalNotInit = notBlock.init;
|
|
367
|
-
notBlock.init = function () {
|
|
368
|
-
originalNotInit.call(this);
|
|
369
|
-
this.inputList[0].appendField(new Blockly.FieldImage(ocargo.Drawing.imageDir + 'empty.svg',
|
|
370
|
-
ocargo.BlocklyControl.EXTRA_BLOCK_WIDTH,
|
|
371
|
-
ocargo.BlocklyControl.BLOCK_HEIGHT));
|
|
372
|
-
};
|
|
389
|
+
);
|
|
390
|
+
this.appendDummyInput("Event")
|
|
391
|
+
.appendField(gettext("On "))
|
|
392
|
+
.appendField(dropdown, "TYPE")
|
|
393
|
+
.appendField(
|
|
394
|
+
new Blockly.FieldImage(
|
|
395
|
+
ocargo.Drawing.imageDir + ocargo.Drawing.whiteCowUrl,
|
|
396
|
+
ocargo.BlocklyControl.COW_WIDTH,
|
|
397
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
398
|
+
),
|
|
399
|
+
"IMAGE"
|
|
400
|
+
);
|
|
401
|
+
this.getField("IMAGE").EDITABLE = true; //saves the image path as well in the XML
|
|
402
|
+
this.appendStatementInput("DO")
|
|
403
|
+
.setCheck("EventAction")
|
|
404
|
+
.appendField(gettext("Do"));
|
|
405
|
+
this.setTooltip(gettext("Declares the event handler"));
|
|
406
|
+
this.statementConnection_ = null;
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
/*******************/
|
|
411
|
+
/* Control Flows */
|
|
412
|
+
/*******************/
|
|
413
|
+
|
|
414
|
+
Blockly.Blocks["controls_repeat_while"] = {
|
|
415
|
+
// Block for repeat while
|
|
416
|
+
init: function () {
|
|
417
|
+
this.setColour(120);
|
|
418
|
+
this.appendValueInput("condition")
|
|
419
|
+
.setCheck("Boolean")
|
|
420
|
+
.appendField(Blockly.Msg.CONTROLS_REPEAT_WHILE_TITLE);
|
|
421
|
+
this.appendStatementInput("body")
|
|
422
|
+
.setCheck("Action")
|
|
423
|
+
.appendField(Blockly.Msg.CONTROLS_REPEAT_WHILE_SUBTITLE);
|
|
424
|
+
this.setPreviousStatement(true, "Action");
|
|
425
|
+
this.setNextStatement(true, "Action");
|
|
426
|
+
this.setTooltip(Blockly.Msg.CONTROLS_REPEAT_WHILE_TOOLTIP);
|
|
427
|
+
},
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
Blockly.Blocks["controls_repeat_until"] = {
|
|
431
|
+
// Block for repeat until
|
|
432
|
+
init: function () {
|
|
433
|
+
this.setColour(120);
|
|
434
|
+
this.appendValueInput("condition")
|
|
435
|
+
.setCheck("Boolean")
|
|
436
|
+
.appendField(Blockly.Msg.CONTROLS_REPEAT_UNTIL_TITLE);
|
|
437
|
+
this.appendStatementInput("body")
|
|
438
|
+
.setCheck("Action")
|
|
439
|
+
.appendField(Blockly.Msg.CONTROLS_REPEAT_UNTIL_SUBTITLE);
|
|
440
|
+
this.setPreviousStatement(true, "Action");
|
|
441
|
+
this.setNextStatement(true, "Action");
|
|
442
|
+
this.setTooltip(Blockly.Msg.CONTROLS_REPEAT_UNTIL_TOOLTIP);
|
|
443
|
+
},
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
/*****************/
|
|
447
|
+
/* Variables */
|
|
448
|
+
/*****************/
|
|
449
|
+
|
|
450
|
+
Blockly.Blocks["variables_get"] = {
|
|
451
|
+
init: function () {
|
|
452
|
+
this.appendDummyInput().appendField(
|
|
453
|
+
new Blockly.FieldTextInput(""),
|
|
454
|
+
"NAME"
|
|
455
|
+
);
|
|
456
|
+
this.setOutput(true, null);
|
|
457
|
+
this.setColour(330);
|
|
458
|
+
this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);
|
|
459
|
+
},
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
Blockly.Blocks["variables_set"] = {
|
|
463
|
+
init: function () {
|
|
464
|
+
this.appendValueInput("VALUE")
|
|
465
|
+
.setCheck(null)
|
|
466
|
+
.appendField(Blockly.Msg.VARIABLES_SET_TITLE)
|
|
467
|
+
.appendField(new Blockly.FieldTextInput(""), "VAR")
|
|
468
|
+
.appendField(Blockly.Msg.VARIABLES_SET_SUBTITLE);
|
|
469
|
+
this.setPreviousStatement(true, null);
|
|
470
|
+
this.setNextStatement(true, null);
|
|
471
|
+
this.setColour(330);
|
|
472
|
+
this.setTooltip(Blockly.Msg.VARIABLES_SET_TOOLTIP);
|
|
473
|
+
},
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
Blockly.Blocks["variables_numeric_set"] = {
|
|
477
|
+
init: function () {
|
|
478
|
+
this.appendDummyInput()
|
|
479
|
+
.appendField(Blockly.Msg.VARIABLES_SET_TITLE)
|
|
480
|
+
.appendField(new Blockly.FieldTextInput(""), "NAME")
|
|
481
|
+
.appendField(Blockly.Msg.VARIABLES_SET_SUBTITLE)
|
|
482
|
+
.appendField(new Blockly.FieldNumber(0), "VALUE");
|
|
483
|
+
this.setPreviousStatement(true, null);
|
|
484
|
+
this.setNextStatement(true, null);
|
|
485
|
+
this.setColour(330);
|
|
486
|
+
this.setTooltip(Blockly.Msg.VARIABLES_NUMERIC_SET_TOOLTIP);
|
|
487
|
+
},
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
Blockly.Blocks["variables_increment"] = {
|
|
491
|
+
init: function () {
|
|
492
|
+
this.appendDummyInput()
|
|
493
|
+
.appendField(Blockly.Msg.VARIABLES_INCREMENT_TITLE)
|
|
494
|
+
.appendField(new Blockly.FieldTextInput(""), "NAME")
|
|
495
|
+
.appendField(Blockly.Msg.VARIABLES_INCREMENT_SUBTITLE)
|
|
496
|
+
.appendField(new Blockly.FieldNumber(0), "VALUE");
|
|
497
|
+
this.setPreviousStatement(true, null);
|
|
498
|
+
this.setNextStatement(true, null);
|
|
499
|
+
this.setColour(330);
|
|
500
|
+
this.setTooltip(Blockly.Msg.VARIABLES_INCREMENT_TOOLTIP);
|
|
501
|
+
},
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
/***************/
|
|
505
|
+
/* Numbers */
|
|
506
|
+
/***************/
|
|
507
|
+
|
|
508
|
+
Blockly.Blocks["math_number"] = {
|
|
509
|
+
init: function () {
|
|
510
|
+
this.appendDummyInput()
|
|
511
|
+
.appendField(Blockly.Msg.NUMBER_TITLE)
|
|
512
|
+
.appendField(new Blockly.FieldNumber(0), "NUM");
|
|
513
|
+
this.setOutput(true, null);
|
|
514
|
+
this.setColour(230);
|
|
515
|
+
this.setTooltip(Blockly.Msg.NUMBER_TOOLTIP);
|
|
516
|
+
},
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// Set text colour to red
|
|
520
|
+
var textBlock = Blockly.Blocks["text"];
|
|
521
|
+
var originalTextInit = textBlock.init;
|
|
522
|
+
textBlock.init = function () {
|
|
523
|
+
originalTextInit.call(this);
|
|
524
|
+
this.setColour(260);
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
//Customise controls_repeat block to not allow more than a sensible number of repetitions
|
|
528
|
+
var controlsRepeatBlock = Blockly.Blocks["controls_repeat"];
|
|
529
|
+
var originalInit = controlsRepeatBlock.init;
|
|
530
|
+
controlsRepeatBlock.init = function () {
|
|
531
|
+
originalInit.call(this);
|
|
532
|
+
|
|
533
|
+
this.setPreviousStatement(!0, "Action");
|
|
534
|
+
this.setNextStatement(!0, "Action");
|
|
535
|
+
this.inputList[1].setCheck("Action"); //Disallow event action blocks to be in body
|
|
536
|
+
|
|
537
|
+
var input = this.inputList[0];
|
|
538
|
+
var field = input.fieldRow[1];
|
|
539
|
+
field.changeHandler_ = function (text) {
|
|
540
|
+
var n = Blockly.FieldTextInput.numberValidator(text);
|
|
541
|
+
if (n) {
|
|
542
|
+
n = String(Math.min(Math.max(0, Math.floor(n)), 20));
|
|
543
|
+
}
|
|
544
|
+
return n;
|
|
545
|
+
};
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
// Make 'not' taller
|
|
549
|
+
var notBlock = Blockly.Blocks["logic_negate"];
|
|
550
|
+
var originalNotInit = notBlock.init;
|
|
551
|
+
notBlock.init = function () {
|
|
552
|
+
originalNotInit.call(this);
|
|
553
|
+
this.inputList[0].appendField(
|
|
554
|
+
new Blockly.FieldImage(
|
|
555
|
+
ocargo.Drawing.imageDir + "empty.svg",
|
|
556
|
+
ocargo.BlocklyControl.EXTRA_BLOCK_WIDTH,
|
|
557
|
+
ocargo.BlocklyControl.BLOCK_HEIGHT
|
|
558
|
+
)
|
|
559
|
+
);
|
|
560
|
+
};
|
|
373
561
|
}
|
|
374
562
|
|
|
375
563
|
function initCustomBlocksPython() {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
Blockly.Python
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
Blockly.Python
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
Blockly.Python
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
Blockly.Python
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
564
|
+
Blockly.Python["start"] = function (block) {
|
|
565
|
+
return "";
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
Blockly.Python["move_forwards"] = function (block) {
|
|
569
|
+
return "my_van.move_forwards()\n";
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
Blockly.Python["turn_left"] = function (block) {
|
|
573
|
+
return "my_van.turn_left()\n";
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
Blockly.Python["turn_right"] = function (block) {
|
|
577
|
+
return "my_van.turn_right()\n";
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
Blockly.Python["turn_around"] = function (block) {
|
|
581
|
+
return "my_van.turn_around()\n";
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
Blockly.Python["wait"] = function (block) {
|
|
585
|
+
return "my_van.wait()\n";
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
Blockly.Python["deliver"] = function (block) {
|
|
589
|
+
return "my_van.deliver()\n";
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
Blockly.Python["sound_horn"] = function (block) {
|
|
593
|
+
return "my_van.sound_horn()\n";
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
Blockly.Python["road_exists"] = function (block) {
|
|
597
|
+
if (block.inputList[0].fieldRow[1].value_ === "FORWARD") {
|
|
598
|
+
var python = "my_van.is_road_forward()";
|
|
599
|
+
} else if (block.inputList[0].fieldRow[1].value_ === "LEFT") {
|
|
600
|
+
var python = "my_van.is_road_left()";
|
|
601
|
+
} else {
|
|
602
|
+
var python = "my_van.is_road_right()";
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
return [python, Blockly.Python.ORDER_NONE];
|
|
606
|
+
// TODO: figure out what this ordering relates to
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
Blockly.Python["traffic_light"] = function (block) {
|
|
610
|
+
var python;
|
|
611
|
+
if (block.inputList[0].fieldRow[1].value_ === ocargo.TrafficLight.RED) {
|
|
612
|
+
python = "my_van.is_red_traffic_light()";
|
|
613
|
+
} else {
|
|
614
|
+
python = "my_van.is_green_traffic_light()";
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
return [python, Blockly.Python.ORDER_NONE]; //TODO: figure out what this ordering relates to
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
Blockly.Python["dead_end"] = function (block) {
|
|
621
|
+
return ["my_van.at_dead_end()", Blockly.Python.ORDER_NONE];
|
|
622
|
+
// TODO: figure out what this ordering relates to
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
Blockly.Python["cow_crossing"] = function (block) {
|
|
626
|
+
return ["my_van.is_animal_crossing()", Blockly.Python.ORDER_NONE];
|
|
627
|
+
// TODO: figure out what this ordering relates to
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
Blockly.Python["at_destination"] = function (block) {
|
|
631
|
+
return ["my_van.at_destination()", Blockly.Python.ORDER_NONE];
|
|
632
|
+
// TODO: figure out what this ordering relates to;
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
Blockly.Python["call_proc"] = function (block) {
|
|
636
|
+
return block.inputList[0].fieldRow[2].text_ + "()\n";
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
Blockly.Python["declare_proc"] = function (block) {
|
|
640
|
+
var branch = Blockly.Python.statementToCode(block, "DO");
|
|
641
|
+
return "def " + block.inputList[0].fieldRow[1].text_ + "():\n" + branch;
|
|
642
|
+
// TODO: get code out of sub-blocks (there's a Blockly function for it)
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
Blockly.Python["declare_event"] = function (block) {
|
|
646
|
+
// TODO support events in python
|
|
647
|
+
throw "events not supported in python";
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
Blockly.Python["controls_repeat_while"] = function (block) {
|
|
651
|
+
var condition = Blockly.Python.valueToCode(
|
|
652
|
+
block,
|
|
653
|
+
"condition",
|
|
654
|
+
Blockly.Python.ORDER_ATOMIC
|
|
655
|
+
);
|
|
656
|
+
|
|
657
|
+
condition = condition.replace(/\((.*)\)/, "$1");
|
|
658
|
+
|
|
659
|
+
var subBlock = Blockly.Python.statementToCode(block, "body");
|
|
660
|
+
var code = "while " + condition + ":\n" + subBlock;
|
|
661
|
+
return code;
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
Blockly.Python["controls_repeat_until"] = function (block) {
|
|
665
|
+
var condition = Blockly.Python.valueToCode(
|
|
666
|
+
block,
|
|
667
|
+
"condition",
|
|
668
|
+
Blockly.Python.ORDER_ATOMIC
|
|
669
|
+
);
|
|
670
|
+
var subBlock = Blockly.Python.statementToCode(block, "body");
|
|
671
|
+
var code = "while not " + condition + ":\n" + subBlock;
|
|
672
|
+
return code;
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
Blockly.Python["variables_get"] = function (block) {
|
|
676
|
+
var variableName = block.getFieldValue("NAME");
|
|
677
|
+
return [variableName, Blockly.Python.ORDER_ATOMIC];
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
Blockly.Python["variables_set"] = function (block) {
|
|
681
|
+
var variableName = block.getFieldValue("VAR");
|
|
682
|
+
var value = Blockly.Python.valueToCode(
|
|
683
|
+
block,
|
|
684
|
+
"VALUE",
|
|
685
|
+
Blockly.Python.ORDER_NONE
|
|
686
|
+
);
|
|
687
|
+
var code = `${variableName} = ${value}\n`;
|
|
688
|
+
return code;
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
Blockly.Python["variables_numeric_set"] = function (block) {
|
|
692
|
+
var variableName = block.getFieldValue("NAME");
|
|
693
|
+
var numberValue = block.getFieldValue("VALUE");
|
|
694
|
+
var code = `${variableName} = ${numberValue}\n`;
|
|
695
|
+
return code;
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
Blockly.Python["variables_increment"] = function (block) {
|
|
699
|
+
var variableName = block.getFieldValue("NAME");
|
|
700
|
+
var numberValue = block.getFieldValue("VALUE");
|
|
701
|
+
var code = `${variableName} = ${variableName} + ${numberValue}\n`;
|
|
702
|
+
return code;
|
|
703
|
+
};
|
|
471
704
|
}
|