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,46 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
var ocargo = ocargo || {};
|
|
4
4
|
|
|
5
|
-
ocargo.BlocklyCompiler = function() {};
|
|
5
|
+
ocargo.BlocklyCompiler = function () {};
|
|
6
6
|
|
|
7
7
|
ocargo.BlocklyCompiler.prototype.procedureBindings = null;
|
|
8
8
|
ocargo.BlocklyCompiler.prototype.procedures = null;
|
|
9
9
|
ocargo.BlocklyCompiler.prototype.events = null;
|
|
10
10
|
ocargo.BlocklyCompiler.prototype.program = null;
|
|
11
11
|
|
|
12
|
-
ocargo.BlocklyCompiler.prototype.compile = function() {
|
|
12
|
+
ocargo.BlocklyCompiler.prototype.compile = function () {
|
|
13
13
|
this.compileProcedures();
|
|
14
14
|
this.compileEvents();
|
|
15
15
|
this.compileProgram();
|
|
16
16
|
this.bindProcedureCalls();
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
return this.program;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
ocargo.BlocklyCompiler.prototype.compileProcedures = function() {
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
ocargo.BlocklyCompiler.prototype.compileProcedures = function () {
|
|
22
|
+
this.procedures = {};
|
|
23
|
+
this.procedureBindings = [];
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
var procBlocks = ocargo.blocklyControl.procedureBlocks();
|
|
26
|
+
for (var i = 0; i < procBlocks.length; i++) {
|
|
27
|
+
var block = procBlocks[i];
|
|
28
|
+
var name = block.inputList[0].fieldRow[1].text_;
|
|
29
|
+
if (name === "") {
|
|
30
|
+
throw gettext_noop("Perhaps try looking at your 'define' blocks?");
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
var bodyBlock = block.inputList[1].connection.targetBlock();
|
|
34
|
+
if (bodyBlock === null) {
|
|
35
|
+
throw gettext_noop("Perhaps try looking at your 'define' blocks?");
|
|
36
|
+
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
if (!(name in this.procedures)) {
|
|
39
|
+
this.procedures[name] = new Procedure(
|
|
40
|
+
name,
|
|
41
|
+
this.createSequence(bodyBlock),
|
|
42
|
+
block
|
|
43
|
+
);
|
|
44
|
+
} else {
|
|
45
|
+
throw gettext_noop(
|
|
46
|
+
"Perhaps try checking the names of your 'define' blocks?"
|
|
47
|
+
);
|
|
43
48
|
}
|
|
49
|
+
}
|
|
44
50
|
};
|
|
45
51
|
|
|
46
52
|
ocargo.BlocklyCompiler.prototype.compileEvents = function() {
|
|
@@ -73,456 +79,608 @@ ocargo.BlocklyCompiler.prototype.compileProgram = function() {
|
|
|
73
79
|
this.program.thread = thread;
|
|
74
80
|
};
|
|
75
81
|
|
|
76
|
-
ocargo.BlocklyCompiler.prototype.bindProcedureCalls = function() {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
ocargo.BlocklyCompiler.prototype.bindProcedureCalls = function () {
|
|
83
|
+
this.program.procedures = this.procedures;
|
|
84
|
+
for (var i = 0; i < this.procedureBindings.length; i++) {
|
|
85
|
+
var name = this.procedureBindings[i].name;
|
|
86
|
+
var call = this.procedureBindings[i].call;
|
|
87
|
+
|
|
88
|
+
if (name in this.procedures) {
|
|
89
|
+
call.bind(this.procedures[name]);
|
|
90
|
+
} else {
|
|
91
|
+
throw gettext_noop(
|
|
92
|
+
"Perhaps try checking the names in your 'call' blocks?"
|
|
93
|
+
);
|
|
87
94
|
}
|
|
95
|
+
}
|
|
88
96
|
};
|
|
89
97
|
|
|
90
98
|
/** Instructions **/
|
|
91
99
|
|
|
92
100
|
// New completely custom repeat until and repeat while blocks
|
|
93
101
|
|
|
94
|
-
ocargo.BlocklyCompiler.prototype.createRepeatUntil = function(block) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
ocargo.BlocklyCompiler.prototype.createRepeatUntil = function (block) {
|
|
103
|
+
var conditionBlock = block.inputList[0].connection.targetBlock();
|
|
104
|
+
if (conditionBlock === null) {
|
|
105
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
106
|
+
}
|
|
107
|
+
var condition = this.getCondition(conditionBlock);
|
|
108
|
+
// negate condition for repeat until
|
|
109
|
+
condition = this.negateCondition(condition);
|
|
110
|
+
|
|
111
|
+
var bodyBlock = block.inputList[1].connection.targetBlock();
|
|
112
|
+
if (bodyBlock === null) {
|
|
113
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
114
|
+
}
|
|
115
|
+
return new While(condition, this.createSequence(bodyBlock), block);
|
|
116
|
+
};
|
|
102
117
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
118
|
+
ocargo.BlocklyCompiler.prototype.createRepeatWhile = function (block) {
|
|
119
|
+
var conditionBlock = block.inputList[0].connection.targetBlock();
|
|
120
|
+
if (conditionBlock === null) {
|
|
121
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
122
|
+
}
|
|
123
|
+
var condition = this.getCondition(conditionBlock);
|
|
124
|
+
|
|
125
|
+
var bodyBlock = block.inputList[1].connection.targetBlock();
|
|
126
|
+
if (bodyBlock === null) {
|
|
127
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
128
|
+
}
|
|
129
|
+
return new While(condition, this.createSequence(bodyBlock), block);
|
|
108
130
|
};
|
|
109
131
|
|
|
110
|
-
ocargo.BlocklyCompiler.prototype.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var condition = this.getCondition(conditionBlock);
|
|
132
|
+
ocargo.BlocklyCompiler.prototype.createProcedureCall = function (block) {
|
|
133
|
+
var name = block.inputList[0].fieldRow[2].text_;
|
|
134
|
+
if (name === "") {
|
|
135
|
+
throw gettext_noop("Perhaps try checking the names in your 'call' blocks?");
|
|
136
|
+
}
|
|
116
137
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
return new While(condition, this.createSequence(bodyBlock), block);
|
|
138
|
+
var procCall = new ProcedureCall(block);
|
|
139
|
+
this.procedureBindings.push({ call: procCall, name: name });
|
|
140
|
+
return procCall;
|
|
122
141
|
};
|
|
123
142
|
|
|
124
|
-
ocargo.BlocklyCompiler.prototype.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
143
|
+
ocargo.BlocklyCompiler.prototype.createVariable = function (block) {
|
|
144
|
+
var variableName = block.inputList[0].fieldRow[1].text_;
|
|
145
|
+
if (variableName === "") {
|
|
146
|
+
throw gettext_noop(
|
|
147
|
+
"Perhaps try checking the names in your 'set variable' blocks?"
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var self = this;
|
|
152
|
+
var variableValueFunction = function () {
|
|
153
|
+
return self.getValue(block.inputList[0].connection.targetBlock());
|
|
154
|
+
};
|
|
129
155
|
|
|
130
|
-
|
|
131
|
-
this.procedureBindings.push({call:procCall,name:name});
|
|
132
|
-
return procCall;
|
|
156
|
+
return new SetVariableCommand(block, variableName, variableValueFunction);
|
|
133
157
|
};
|
|
134
158
|
|
|
135
|
-
ocargo.BlocklyCompiler.prototype.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
159
|
+
ocargo.BlocklyCompiler.prototype.createVariableNumeric = function (block) {
|
|
160
|
+
var variableName = block.inputList[0].fieldRow[1].text_;
|
|
161
|
+
if (variableName === "") {
|
|
162
|
+
throw gettext_noop(
|
|
163
|
+
"Perhaps try checking the names in your 'set variable' blocks?"
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
var variableValueFunction = function () {
|
|
168
|
+
var variableValue = parseInt(block.getFieldValue("VALUE"));
|
|
169
|
+
if (variableValue === "") {
|
|
170
|
+
throw gettext_noop(
|
|
171
|
+
"Perhaps try checking the values in your 'set variable' blocks?"
|
|
172
|
+
);
|
|
139
173
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
174
|
+
return variableValue;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
return new SetVariableCommand(block, variableName, variableValueFunction);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
ocargo.BlocklyCompiler.prototype.incrementVariable = function (block) {
|
|
181
|
+
var variableName = block.inputList[0].fieldRow[1].text_;
|
|
182
|
+
if (variableName === "") {
|
|
183
|
+
throw gettext_noop(
|
|
184
|
+
"Perhaps try checking the names in your 'increment variable' blocks?"
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
var variableIncrValue = parseInt(block.getFieldValue("VALUE"));
|
|
189
|
+
if (variableIncrValue === "") {
|
|
190
|
+
throw gettext_noop(
|
|
191
|
+
"Perhaps try checking the values in your 'increment variable' blocks?"
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return new IncrementVariableCommand(block, variableName, variableIncrValue);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
ocargo.BlocklyCompiler.prototype.createRepeat = function (block) {
|
|
199
|
+
var bodyBlock = block.inputList[1].connection.targetBlock();
|
|
200
|
+
if (bodyBlock === null) {
|
|
201
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
202
|
+
}
|
|
203
|
+
return new While(
|
|
204
|
+
this.counterCondition(
|
|
205
|
+
block,
|
|
206
|
+
parseInt(block.inputList[0].fieldRow[1].text_)
|
|
207
|
+
),
|
|
208
|
+
this.createSequence(bodyBlock),
|
|
209
|
+
block
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
ocargo.BlocklyCompiler.prototype.createWhileUntil = function (block) {
|
|
214
|
+
var conditionBlock = block.inputList[0].connection.targetBlock();
|
|
215
|
+
if (conditionBlock === null) {
|
|
216
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
217
|
+
}
|
|
218
|
+
var condition = this.getCondition(conditionBlock);
|
|
219
|
+
if (block.inputList[0].fieldRow[1].value_ == "UNTIL") {
|
|
220
|
+
condition = this.negateCondition(condition);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
var bodyBlock = block.inputList[1].connection.targetBlock();
|
|
224
|
+
if (bodyBlock === null) {
|
|
225
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
226
|
+
}
|
|
227
|
+
return new While(condition, this.createSequence(bodyBlock), block);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
ocargo.BlocklyCompiler.prototype.getCondition = function (conditionBlock) {
|
|
231
|
+
if (conditionBlock.type === "road_exists") {
|
|
232
|
+
var selection = conditionBlock.inputList[0].fieldRow[1].value_;
|
|
233
|
+
return this.roadCondition(conditionBlock, selection);
|
|
234
|
+
} else if (conditionBlock.type === "dead_end") {
|
|
235
|
+
return this.deadEndCondition(conditionBlock);
|
|
236
|
+
} else if (conditionBlock.type === "at_destination") {
|
|
237
|
+
return this.atDestinationCondition(conditionBlock);
|
|
238
|
+
} else if (conditionBlock.type === "logic_negate") {
|
|
239
|
+
return this.negateCondition(
|
|
240
|
+
this.getCondition(conditionBlock.inputList[0].connection.targetBlock())
|
|
241
|
+
);
|
|
242
|
+
} else if (conditionBlock.type === "traffic_light") {
|
|
243
|
+
return this.trafficLightCondition(conditionBlock);
|
|
244
|
+
} else if (conditionBlock.type === "cow_crossing") {
|
|
245
|
+
return this.cowCrossingCondition(conditionBlock);
|
|
246
|
+
} else if (conditionBlock.type === "logic_compare") {
|
|
247
|
+
return this.logicCompareCondition(conditionBlock);
|
|
248
|
+
}
|
|
144
249
|
};
|
|
145
250
|
|
|
146
|
-
ocargo.BlocklyCompiler.prototype.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
251
|
+
ocargo.BlocklyCompiler.prototype.getValue = function (block) {
|
|
252
|
+
if (block.type === "variables_get") {
|
|
253
|
+
var variableName = block.inputList[0].fieldRow[0].text_;
|
|
254
|
+
return parseInt(this.program.variables[variableName]);
|
|
255
|
+
} else if (block.type === "math_number") {
|
|
256
|
+
return parseInt(block.getFieldValue("NUM"));
|
|
257
|
+
} else if (block.type === "math_arithmetic") {
|
|
258
|
+
var leftBlock = block.inputList[0].connection.targetBlock();
|
|
259
|
+
var rightBlock = block.inputList[1].connection.targetBlock();
|
|
260
|
+
if (leftBlock === null || rightBlock === null) {
|
|
261
|
+
throw gettext_noop(
|
|
262
|
+
"Perhaps try looking at your 'math arithmetic' blocks?"
|
|
263
|
+
);
|
|
150
264
|
}
|
|
151
|
-
var condition = this.getCondition(conditionBlock);
|
|
152
|
-
if (block.inputList[0].fieldRow[1].value_ == 'UNTIL') {
|
|
153
|
-
condition = this.negateCondition(condition);
|
|
154
|
-
}
|
|
155
265
|
|
|
156
|
-
var
|
|
157
|
-
|
|
158
|
-
|
|
266
|
+
var operator = block.getFieldValue("OP");
|
|
267
|
+
var leftValue = this.getValue(leftBlock);
|
|
268
|
+
var rightValue = this.getValue(rightBlock);
|
|
269
|
+
|
|
270
|
+
if (operator == "ADD") {
|
|
271
|
+
return leftValue + rightValue;
|
|
272
|
+
} else if (operator == "MINUS") {
|
|
273
|
+
return leftValue - rightValue;
|
|
274
|
+
} else if (operator == "MULTIPLY") {
|
|
275
|
+
return leftValue * rightValue;
|
|
276
|
+
} else if (operator == "DIVIDE") {
|
|
277
|
+
return leftValue / rightValue;
|
|
278
|
+
} else if (operator == "POWER") {
|
|
279
|
+
return leftValue ** rightValue;
|
|
159
280
|
}
|
|
160
|
-
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
ocargo.BlocklyCompiler.prototype.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
ocargo.BlocklyCompiler.prototype.createIf = function (block) {
|
|
285
|
+
var conditionalCommandSets = [];
|
|
286
|
+
|
|
287
|
+
var elseCount = block.elseCount_ || 0;
|
|
288
|
+
var i = 0;
|
|
289
|
+
while (i < block.inputList.length - elseCount) {
|
|
290
|
+
var input = block.inputList[i];
|
|
291
|
+
var condition;
|
|
292
|
+
|
|
293
|
+
if (input.name.indexOf("IF") === 0) {
|
|
294
|
+
var conditionBlock = input.connection.targetBlock();
|
|
295
|
+
if (conditionBlock === null) {
|
|
296
|
+
throw gettext_noop("Perhaps try looking at your 'if' blocks?");
|
|
297
|
+
}
|
|
298
|
+
condition = this.getCondition(conditionBlock);
|
|
299
|
+
} else if (input.name.indexOf("DO") === 0) {
|
|
300
|
+
var conditionalCommandSet = {};
|
|
301
|
+
conditionalCommandSet.condition = condition;
|
|
302
|
+
conditionalCommandSet.commands = this.createSequence(
|
|
303
|
+
input.connection.targetBlock()
|
|
304
|
+
);
|
|
305
|
+
conditionalCommandSets.push(conditionalCommandSet);
|
|
178
306
|
}
|
|
307
|
+
|
|
308
|
+
i++;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (elseCount === 1) {
|
|
312
|
+
var elseBody = this.createSequence(
|
|
313
|
+
block.inputList[block.inputList.length - 1].connection.targetBlock()
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return new If(conditionalCommandSets, elseBody, block);
|
|
179
318
|
};
|
|
180
319
|
|
|
181
|
-
ocargo.BlocklyCompiler.prototype.
|
|
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
|
-
if (block.type === 'move_forwards') {
|
|
219
|
-
commands.push(new ForwardCommand(block));
|
|
220
|
-
} else if (block.type === 'turn_left') {
|
|
221
|
-
commands.push(new TurnLeftCommand(block));
|
|
222
|
-
} else if (block.type === 'turn_right') {
|
|
223
|
-
commands.push(new TurnRightCommand(block));
|
|
224
|
-
} else if (block.type === 'turn_around') {
|
|
225
|
-
commands.push(new TurnAroundCommand(block));
|
|
226
|
-
} else if (block.type === 'wait') {
|
|
227
|
-
commands.push(new WaitCommand(block));
|
|
228
|
-
} else if (block.type === 'deliver') {
|
|
229
|
-
commands.push(new DeliverCommand(block));
|
|
230
|
-
} else if (block.type === 'sound_horn') {
|
|
231
|
-
commands.push(new SoundHornCommand(block));
|
|
232
|
-
} else if (block.type === 'puff_up') {
|
|
233
|
-
commands.push(new PuffUpCommand(block));
|
|
234
|
-
} else if (block.type === 'controls_repeat_until') {
|
|
235
|
-
commands.push(this.createRepeatUntil(block));
|
|
236
|
-
} else if (block.type === 'controls_repeat_while') {
|
|
237
|
-
commands.push(this.createRepeatWhile(block));
|
|
238
|
-
} else if (block.type === 'controls_repeat') {
|
|
239
|
-
commands.push(this.createRepeat(block));
|
|
240
|
-
} else if (block.type === 'controls_whileUntil') {
|
|
241
|
-
commands.push(this.createWhileUntil(block));
|
|
242
|
-
} else if (block.type === 'controls_if') {
|
|
243
|
-
commands.push(this.createIf(block));
|
|
244
|
-
} else if (block.type === 'call_proc') {
|
|
245
|
-
commands.push(this.createProcedureCall(block));
|
|
246
|
-
}
|
|
320
|
+
ocargo.BlocklyCompiler.prototype.createSequence = function (block) {
|
|
321
|
+
var commands = [];
|
|
322
|
+
|
|
323
|
+
while (block) {
|
|
324
|
+
if (block.type === "move_forwards") {
|
|
325
|
+
commands.push(new ForwardCommand(block));
|
|
326
|
+
} else if (block.type === "turn_left") {
|
|
327
|
+
commands.push(new TurnLeftCommand(block));
|
|
328
|
+
} else if (block.type === "turn_right") {
|
|
329
|
+
commands.push(new TurnRightCommand(block));
|
|
330
|
+
} else if (block.type === "turn_around") {
|
|
331
|
+
commands.push(new TurnAroundCommand(block));
|
|
332
|
+
} else if (block.type === "wait") {
|
|
333
|
+
commands.push(new WaitCommand(block));
|
|
334
|
+
} else if (block.type === "deliver") {
|
|
335
|
+
commands.push(new DeliverCommand(block));
|
|
336
|
+
} else if (block.type === "sound_horn") {
|
|
337
|
+
commands.push(new SoundHornCommand(block));
|
|
338
|
+
} else if (block.type === "controls_repeat_until") {
|
|
339
|
+
commands.push(this.createRepeatUntil(block));
|
|
340
|
+
} else if (block.type === "controls_repeat_while") {
|
|
341
|
+
commands.push(this.createRepeatWhile(block));
|
|
342
|
+
} else if (block.type === "controls_repeat") {
|
|
343
|
+
commands.push(this.createRepeat(block));
|
|
344
|
+
} else if (block.type === "controls_whileUntil") {
|
|
345
|
+
commands.push(this.createWhileUntil(block));
|
|
346
|
+
} else if (block.type === "controls_if") {
|
|
347
|
+
commands.push(this.createIf(block));
|
|
348
|
+
} else if (block.type === "call_proc") {
|
|
349
|
+
commands.push(this.createProcedureCall(block));
|
|
350
|
+
} else if (block.type === "variables_set") {
|
|
351
|
+
commands.push(this.createVariable(block));
|
|
352
|
+
} else if (block.type === "variables_numeric_set") {
|
|
353
|
+
commands.push(this.createVariableNumeric(block));
|
|
354
|
+
} else if (block.type === "variables_increment") {
|
|
355
|
+
commands.push(this.incrementVariable(block));
|
|
356
|
+
}
|
|
247
357
|
|
|
248
|
-
|
|
249
|
-
|
|
358
|
+
block = block.nextConnection ? block.nextConnection.targetBlock() : null;
|
|
359
|
+
}
|
|
250
360
|
|
|
251
|
-
|
|
361
|
+
return commands;
|
|
252
362
|
};
|
|
253
363
|
|
|
254
|
-
ocargo.BlocklyCompiler.prototype.simplifyBlock = function(block){
|
|
255
|
-
|
|
364
|
+
ocargo.BlocklyCompiler.prototype.simplifyBlock = function (block) {
|
|
365
|
+
return new Block(block.id, block.type);
|
|
256
366
|
};
|
|
257
367
|
|
|
258
368
|
/** Conditions **/
|
|
259
369
|
|
|
260
|
-
ocargo.BlocklyCompiler.prototype.trafficLightCondition = function(block) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
ocargo.BlocklyCompiler.prototype.roadCondition = function(block, selection) {
|
|
274
|
-
return function(model) {
|
|
275
|
-
queueHighlight(model, block);
|
|
276
|
-
if (selection === 'FORWARD') {
|
|
277
|
-
return model.isRoadForward();
|
|
278
|
-
} else if (selection === 'LEFT') {
|
|
279
|
-
return model.isRoadLeft();
|
|
280
|
-
} else if (selection === 'RIGHT') {
|
|
281
|
-
return model.isRoadRight();
|
|
282
|
-
}
|
|
283
|
-
};
|
|
370
|
+
ocargo.BlocklyCompiler.prototype.trafficLightCondition = function (block) {
|
|
371
|
+
var lightColour = block.getFieldValue("CHOICE");
|
|
372
|
+
return function (model) {
|
|
373
|
+
queueHighlight(model, block);
|
|
374
|
+
if (lightColour === ocargo.TrafficLight.RED) {
|
|
375
|
+
return model.isTrafficLightRed();
|
|
376
|
+
} else if (lightColour === ocargo.TrafficLight.GREEN) {
|
|
377
|
+
return model.isTrafficLightGreen();
|
|
378
|
+
}
|
|
379
|
+
};
|
|
284
380
|
};
|
|
285
381
|
|
|
286
|
-
ocargo.BlocklyCompiler.prototype.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
382
|
+
ocargo.BlocklyCompiler.prototype.roadCondition = function (block, selection) {
|
|
383
|
+
return function (model) {
|
|
384
|
+
queueHighlight(model, block);
|
|
385
|
+
if (selection === "FORWARD") {
|
|
386
|
+
return model.isRoadForward();
|
|
387
|
+
} else if (selection === "LEFT") {
|
|
388
|
+
return model.isRoadLeft();
|
|
389
|
+
} else if (selection === "RIGHT") {
|
|
390
|
+
return model.isRoadRight();
|
|
391
|
+
}
|
|
392
|
+
};
|
|
291
393
|
};
|
|
292
394
|
|
|
293
|
-
ocargo.BlocklyCompiler.prototype.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
395
|
+
ocargo.BlocklyCompiler.prototype.deadEndCondition = function (block) {
|
|
396
|
+
return function (model) {
|
|
397
|
+
queueHighlight(model, block);
|
|
398
|
+
return model.isDeadEnd();
|
|
399
|
+
};
|
|
298
400
|
};
|
|
299
401
|
|
|
402
|
+
ocargo.BlocklyCompiler.prototype.cowCrossingCondition = function (block) {
|
|
403
|
+
return function (model) {
|
|
404
|
+
queueHighlight(model, block);
|
|
405
|
+
return model.isCowCrossing(block.getFieldValue("TYPE"));
|
|
406
|
+
};
|
|
407
|
+
};
|
|
300
408
|
|
|
301
|
-
ocargo.BlocklyCompiler.prototype.negateCondition = function(otherCondition) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
409
|
+
ocargo.BlocklyCompiler.prototype.negateCondition = function (otherCondition) {
|
|
410
|
+
return function (model) {
|
|
411
|
+
return !otherCondition(model);
|
|
412
|
+
};
|
|
305
413
|
};
|
|
306
414
|
|
|
307
|
-
ocargo.BlocklyCompiler.prototype.atDestinationCondition = function(block) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
415
|
+
ocargo.BlocklyCompiler.prototype.atDestinationCondition = function (block) {
|
|
416
|
+
return function (model) {
|
|
417
|
+
queueHighlight(model, block);
|
|
418
|
+
return model.isAtADestination();
|
|
419
|
+
};
|
|
312
420
|
};
|
|
313
421
|
|
|
314
|
-
ocargo.BlocklyCompiler.prototype.counterCondition = function(block, count) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
422
|
+
ocargo.BlocklyCompiler.prototype.counterCondition = function (block, count) {
|
|
423
|
+
var startCount = count;
|
|
424
|
+
return function (model) {
|
|
425
|
+
queueHighlight(model, block);
|
|
426
|
+
if (count > 0) {
|
|
427
|
+
count--;
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
// Resets the counter for nested loops
|
|
431
|
+
count = startCount;
|
|
432
|
+
return false;
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
ocargo.BlocklyCompiler.prototype.logicCompareCondition = function (block) {
|
|
437
|
+
// check left and right blocks
|
|
438
|
+
var leftBlock = block.inputList[0].connection.targetBlock();
|
|
439
|
+
var rightBlock = block.inputList[1].connection.targetBlock();
|
|
440
|
+
if (leftBlock === null || rightBlock === null) {
|
|
441
|
+
throw gettext_noop("Perhaps try looking at your 'compare' blocks?");
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
var operator = block.getFieldValue("OP");
|
|
445
|
+
var self = this;
|
|
446
|
+
|
|
447
|
+
return function (model) {
|
|
448
|
+
queueHighlight(model, block);
|
|
449
|
+
|
|
450
|
+
// get values of left and right blocks - must be evaluated on each step because of variables
|
|
451
|
+
var leftValue = self.getValue(leftBlock);
|
|
452
|
+
var rightValue = self.getValue(rightBlock);
|
|
453
|
+
|
|
454
|
+
if (operator == "EQ") {
|
|
455
|
+
return leftValue === rightValue;
|
|
456
|
+
} else if (operator == "NEQ") {
|
|
457
|
+
return leftValue !== rightValue;
|
|
458
|
+
} else if (operator == "LT") {
|
|
459
|
+
return leftValue < rightValue;
|
|
460
|
+
} else if (operator == "LTE") {
|
|
461
|
+
return leftValue <= rightValue;
|
|
462
|
+
} else if (operator == "GT") {
|
|
463
|
+
return leftValue > rightValue;
|
|
464
|
+
} else if (operator == "GTE") {
|
|
465
|
+
return leftValue >= rightValue;
|
|
466
|
+
}
|
|
467
|
+
};
|
|
326
468
|
};
|
|
327
469
|
|
|
328
470
|
/** Mobile Code **/
|
|
329
471
|
/* Block types in the list passed in from mobile are converted to simplified Block objects
|
|
330
472
|
id is assigned to each block in the order it appears in the array
|
|
331
473
|
*/
|
|
332
|
-
ocargo.BlocklyCompiler.prototype.mobileCompile = function(types) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
474
|
+
ocargo.BlocklyCompiler.prototype.mobileCompile = function (types) {
|
|
475
|
+
var blocks = [];
|
|
476
|
+
for (var i = 0; i < types.length; i++) {
|
|
477
|
+
blocks.push(new Block(i + 1, types[i]));
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
this.program = new ocargo.Program([]);
|
|
481
|
+
var thread = new ocargo.Thread(this.program);
|
|
482
|
+
thread.stack = this.mobileCreateSequence(blocks);
|
|
483
|
+
this.program.thread = thread;
|
|
484
|
+
return this.program;
|
|
485
|
+
};
|
|
337
486
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
commands.push(new TurnRightCommand(block));
|
|
356
|
-
} else if (block.type === 'turn_around') {
|
|
357
|
-
commands.push(new TurnAroundCommand(block));
|
|
358
|
-
} else if (block.type === 'wait') {
|
|
359
|
-
commands.push(new WaitCommand(block));
|
|
360
|
-
} else if (block.type === 'deliver') {
|
|
361
|
-
commands.push(new DeliverCommand(block));
|
|
362
|
-
}
|
|
363
|
-
//} else if (block.type === 'controls_repeat_until') {
|
|
364
|
-
// commands.push(this.mobileCreateRepeatUntil(block));
|
|
365
|
-
//} else if (block.type === 'controls_repeat_while') {
|
|
366
|
-
// commands.push(this.mobileCreateRepeatWhile(block));
|
|
367
|
-
//} else if (block.type === 'controls_repeat') {
|
|
368
|
-
// commands.push(this.mobileCreateRepeat(block));
|
|
369
|
-
//} else if (block.type === 'controls_whileUntil') {
|
|
370
|
-
// commands.push(this.mobileCreateWhileUntil(block));
|
|
371
|
-
//} else if (block.type === 'controls_if') {
|
|
372
|
-
// commands.push(this.mobileCreateIf(block));
|
|
373
|
-
//} else if (block.type === 'call_proc') {
|
|
374
|
-
// commands.push(this.mobileCreateProcedureCall(block));
|
|
375
|
-
//}
|
|
376
|
-
|
|
377
|
-
block = blocks.shift();
|
|
487
|
+
ocargo.BlocklyCompiler.prototype.mobileCreateSequence = function (blocks) {
|
|
488
|
+
var commands = [];
|
|
489
|
+
|
|
490
|
+
var block = blocks.shift();
|
|
491
|
+
while (block) {
|
|
492
|
+
if (block.type === "move_forwards") {
|
|
493
|
+
commands.push(new ForwardCommand(block));
|
|
494
|
+
} else if (block.type === "turn_left") {
|
|
495
|
+
commands.push(new TurnLeftCommand(block));
|
|
496
|
+
} else if (block.type === "turn_right") {
|
|
497
|
+
commands.push(new TurnRightCommand(block));
|
|
498
|
+
} else if (block.type === "turn_around") {
|
|
499
|
+
commands.push(new TurnAroundCommand(block));
|
|
500
|
+
} else if (block.type === "wait") {
|
|
501
|
+
commands.push(new WaitCommand(block));
|
|
502
|
+
} else if (block.type === "deliver") {
|
|
503
|
+
commands.push(new DeliverCommand(block));
|
|
378
504
|
}
|
|
505
|
+
//} else if (block.type === 'controls_repeat_until') {
|
|
506
|
+
// commands.push(this.mobileCreateRepeatUntil(block));
|
|
507
|
+
//} else if (block.type === 'controls_repeat_while') {
|
|
508
|
+
// commands.push(this.mobileCreateRepeatWhile(block));
|
|
509
|
+
//} else if (block.type === 'controls_repeat') {
|
|
510
|
+
// commands.push(this.mobileCreateRepeat(block));
|
|
511
|
+
//} else if (block.type === 'controls_whileUntil') {
|
|
512
|
+
// commands.push(this.mobileCreateWhileUntil(block));
|
|
513
|
+
//} else if (block.type === 'controls_if') {
|
|
514
|
+
// commands.push(this.mobileCreateIf(block));
|
|
515
|
+
//} else if (block.type === 'call_proc') {
|
|
516
|
+
// commands.push(this.mobileCreateProcedureCall(block));
|
|
517
|
+
//}
|
|
379
518
|
|
|
380
|
-
|
|
519
|
+
block = blocks.shift();
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
return commands;
|
|
381
523
|
};
|
|
382
524
|
|
|
383
525
|
/** Instructions **/
|
|
384
526
|
|
|
385
527
|
// New completely custom repeat until and repeat while blocks
|
|
386
528
|
|
|
387
|
-
ocargo.BlocklyCompiler.prototype.mobileCreateRepeatUntil = function(
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
529
|
+
ocargo.BlocklyCompiler.prototype.mobileCreateRepeatUntil = function (
|
|
530
|
+
block,
|
|
531
|
+
conditionBlock
|
|
532
|
+
) {
|
|
533
|
+
var condition;
|
|
534
|
+
if (
|
|
535
|
+
conditionBlock === null ||
|
|
536
|
+
(condition = this.mobileGetCondition(conditionBlock)) === null
|
|
537
|
+
) {
|
|
538
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// negate condition for repeat until
|
|
542
|
+
condition = this.negateCondition(condition);
|
|
543
|
+
|
|
544
|
+
var bodyBlock = block.inputList[1].connection.targetBlock();
|
|
545
|
+
if (bodyBlock === null) {
|
|
546
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
547
|
+
}
|
|
548
|
+
return new While(condition, this.createSequence(bodyBlock), block);
|
|
549
|
+
};
|
|
392
550
|
|
|
393
|
-
|
|
394
|
-
|
|
551
|
+
ocargo.BlocklyCompiler.prototype.mobileCreateRepeatWhile = function (block) {
|
|
552
|
+
var conditionBlock = block.inputList[0].connection.targetBlock();
|
|
553
|
+
if (conditionBlock === null) {
|
|
554
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
555
|
+
}
|
|
556
|
+
var condition = this.getCondition(conditionBlock);
|
|
557
|
+
|
|
558
|
+
var bodyBlock = block.inputList[1].connection.targetBlock();
|
|
559
|
+
if (bodyBlock === null) {
|
|
560
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
561
|
+
}
|
|
562
|
+
return new While(condition, this.createSequence(bodyBlock), block);
|
|
563
|
+
};
|
|
395
564
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
565
|
+
ocargo.BlocklyCompiler.prototype.mobileCreateRepeat = function (block) {
|
|
566
|
+
var bodyBlock = block.inputList[1].connection.targetBlock();
|
|
567
|
+
if (bodyBlock === null) {
|
|
568
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
569
|
+
}
|
|
570
|
+
return new While(
|
|
571
|
+
this.counterCondition(
|
|
572
|
+
block,
|
|
573
|
+
parseInt(block.inputList[0].fieldRow[1].text_)
|
|
574
|
+
),
|
|
575
|
+
this.createSequence(bodyBlock),
|
|
576
|
+
block
|
|
577
|
+
);
|
|
401
578
|
};
|
|
402
579
|
|
|
403
|
-
ocargo.BlocklyCompiler.prototype.
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
580
|
+
ocargo.BlocklyCompiler.prototype.mobileCreateWhileUntil = function (block) {
|
|
581
|
+
var conditionBlock = block.inputList[0].connection.targetBlock();
|
|
582
|
+
if (conditionBlock === null) {
|
|
583
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
584
|
+
}
|
|
585
|
+
var condition = this.getCondition(conditionBlock);
|
|
586
|
+
if (block.inputList[0].fieldRow[1].value_ == "UNTIL") {
|
|
587
|
+
condition = this.negateCondition(condition);
|
|
588
|
+
}
|
|
409
589
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
590
|
+
var bodyBlock = block.inputList[1].connection.targetBlock();
|
|
591
|
+
if (bodyBlock === null) {
|
|
592
|
+
throw gettext_noop("Perhaps try looking at your 'repeat' blocks?");
|
|
593
|
+
}
|
|
594
|
+
return new While(condition, this.createSequence(bodyBlock), block);
|
|
415
595
|
};
|
|
416
596
|
|
|
417
|
-
ocargo.BlocklyCompiler.prototype.
|
|
418
|
-
|
|
419
|
-
if (bodyBlock === null) {
|
|
420
|
-
throw gettext_noop('Perhaps try looking at your \'repeat\' blocks?');
|
|
421
|
-
}
|
|
422
|
-
return new While(
|
|
423
|
-
this.counterCondition(block, parseInt(block.inputList[0].fieldRow[1].text_)),
|
|
424
|
-
this.createSequence(bodyBlock),
|
|
425
|
-
block);
|
|
426
|
-
};
|
|
597
|
+
ocargo.BlocklyCompiler.prototype.mobileCreateIf = function (block) {
|
|
598
|
+
var conditionalCommandSets = [];
|
|
427
599
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
var condition = this.getCondition(conditionBlock);
|
|
434
|
-
if (block.inputList[0].fieldRow[1].value_ == 'UNTIL') {
|
|
435
|
-
condition = this.negateCondition(condition);
|
|
436
|
-
}
|
|
600
|
+
var elseCount = block.elseCount_ || 0;
|
|
601
|
+
var i = 0;
|
|
602
|
+
while (i < block.inputList.length - elseCount) {
|
|
603
|
+
var input = block.inputList[i];
|
|
604
|
+
var condition;
|
|
437
605
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
606
|
+
if (input.name.indexOf("IF") === 0) {
|
|
607
|
+
var conditionBlock = input.connection.targetBlock();
|
|
608
|
+
if (conditionBlock === null) {
|
|
609
|
+
throw gettext_noop("Perhaps try looking at your 'if' blocks?");
|
|
610
|
+
}
|
|
611
|
+
condition = this.getCondition(conditionBlock);
|
|
612
|
+
} else if (input.name.indexOf("DO") === 0) {
|
|
613
|
+
var conditionalCommandSet = {};
|
|
614
|
+
conditionalCommandSet.condition = condition;
|
|
615
|
+
conditionalCommandSet.commands = this.createSequence(
|
|
616
|
+
input.connection.targetBlock()
|
|
617
|
+
);
|
|
618
|
+
conditionalCommandSets.push(conditionalCommandSet);
|
|
441
619
|
}
|
|
442
|
-
return new While(condition, this.createSequence(bodyBlock), block);
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
ocargo.BlocklyCompiler.prototype.mobileCreateIf = function(block) {
|
|
446
|
-
var conditionalCommandSets = [];
|
|
447
|
-
|
|
448
|
-
var elseCount = block.elseCount_ || 0;
|
|
449
|
-
var i = 0;
|
|
450
|
-
while (i < block.inputList.length - elseCount) {
|
|
451
|
-
var input = block.inputList[i];
|
|
452
|
-
var condition;
|
|
453
|
-
|
|
454
|
-
if (input.name.indexOf('IF') === 0) {
|
|
455
|
-
var conditionBlock = input.connection.targetBlock();
|
|
456
|
-
if (conditionBlock === null) {
|
|
457
|
-
throw gettext_noop('Perhaps try looking at your \'if\' blocks?');
|
|
458
|
-
}
|
|
459
|
-
condition = this.getCondition(conditionBlock);
|
|
460
|
-
} else if (input.name.indexOf('DO') === 0) {
|
|
461
|
-
var conditionalCommandSet = {};
|
|
462
|
-
conditionalCommandSet.condition = condition;
|
|
463
|
-
conditionalCommandSet.commands = this.createSequence(input.connection.targetBlock());
|
|
464
|
-
conditionalCommandSets.push(conditionalCommandSet);
|
|
465
|
-
}
|
|
466
620
|
|
|
467
|
-
|
|
468
|
-
|
|
621
|
+
i++;
|
|
622
|
+
}
|
|
469
623
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
624
|
+
if (elseCount === 1) {
|
|
625
|
+
var elseBody = this.createSequence(
|
|
626
|
+
block.inputList[block.inputList.length - 1].connection.targetBlock()
|
|
627
|
+
);
|
|
628
|
+
}
|
|
474
629
|
|
|
475
|
-
|
|
630
|
+
return new If(conditionalCommandSets, elseBody, block);
|
|
476
631
|
};
|
|
477
632
|
|
|
478
|
-
ocargo.BlocklyCompiler.prototype.mobileCreateProcedureCall = function(block) {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
633
|
+
ocargo.BlocklyCompiler.prototype.mobileCreateProcedureCall = function (block) {
|
|
634
|
+
var name = block.inputList[0].fieldRow[2].text_;
|
|
635
|
+
if (name === "") {
|
|
636
|
+
throw gettext_noop("Perhaps try checking the names in your 'call' blocks?");
|
|
637
|
+
}
|
|
483
638
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
ocargo.BlocklyCompiler.prototype.mobileGetCondition = function(
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
639
|
+
var procCall = new ProcedureCall(block);
|
|
640
|
+
this.procedureBindings.push({ call: procCall, name: name });
|
|
641
|
+
return procCall;
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
ocargo.BlocklyCompiler.prototype.mobileGetCondition = function (
|
|
645
|
+
conditionBlock
|
|
646
|
+
) {
|
|
647
|
+
if (conditionBlock.type === "road_exists") {
|
|
648
|
+
var selection = conditionBlock.inputList[0].fieldRow[1].value_;
|
|
649
|
+
return this.roadCondition(conditionBlock, selection);
|
|
650
|
+
} else if (conditionBlock.type === "dead_end") {
|
|
651
|
+
return this.deadEndCondition(conditionBlock);
|
|
652
|
+
} else if (conditionBlock.type === "at_destination") {
|
|
653
|
+
return this.atDestinationCondition(conditionBlock);
|
|
654
|
+
} else if (conditionBlock.type === "logic_negate") {
|
|
655
|
+
return this.negateCondition(
|
|
656
|
+
this.getCondition(conditionBlock.inputList[0].connection.targetBlock())
|
|
657
|
+
);
|
|
658
|
+
} else if (conditionBlock.type === "traffic_light") {
|
|
659
|
+
return this.trafficLightCondition(conditionBlock);
|
|
660
|
+
} else {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
505
663
|
};
|
|
506
664
|
|
|
507
|
-
ocargo.BlocklyCompiler.prototype.workspaceToPython = function() {
|
|
508
|
-
|
|
665
|
+
ocargo.BlocklyCompiler.prototype.workspaceToPython = function () {
|
|
666
|
+
Blockly.Python.variableDB_.reset();
|
|
509
667
|
|
|
510
|
-
|
|
668
|
+
var procBlocks = ocargo.blocklyControl.procedureBlocks();
|
|
511
669
|
|
|
512
|
-
|
|
670
|
+
var code = "";
|
|
513
671
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
672
|
+
for (var i = 0; i < procBlocks.length; i++) {
|
|
673
|
+
code += "\n" + Blockly.Python.blockToCode(procBlocks[i]);
|
|
674
|
+
}
|
|
517
675
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
676
|
+
// TODO support events in python
|
|
677
|
+
//var eventBlocks = ocargo.blocklyControl.onEventDoBlocks();
|
|
678
|
+
//for (var i = 0; i < eventBlocks.length; i++) {
|
|
679
|
+
// code += '\n' + Blockly.Python.blockToCode(eventBlocks[i]);
|
|
680
|
+
//}
|
|
523
681
|
|
|
524
|
-
|
|
525
|
-
|
|
682
|
+
var startBlock = ocargo.blocklyControl.startBlock();
|
|
683
|
+
code += "\n" + Blockly.Python.blockToCode(startBlock);
|
|
526
684
|
|
|
527
|
-
|
|
685
|
+
return code;
|
|
528
686
|
};
|