├── .github └── CONTRIBUTING.md ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── package.json ├── src ├── block_images │ ├── arrows.png │ └── flag.png ├── build_translations.py ├── commands.js ├── defs.css ├── dev.html ├── extra_strings.py ├── index.html ├── inline-dev.html ├── lib │ └── style.css ├── package_commands.py ├── scratchblocks.js ├── translations-all.js └── translations.js └── tests ├── all-blocks-de.txt ├── all-blocks.txt ├── images.txt ├── languages.txt ├── line-test.txt ├── lt-gt.txt ├── of-block.txt ├── snap-hacks.txt ├── stop-block.txt └── stress-test.txt /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Hello! 2 | Thanks for your interest in contributing to scratchblocks. 3 | 4 | The [Community Guidelines](https://github.com/LLK/scratch-www/wiki/Community-Guidelines) for **[scratch-www](https://github.com/LLK/scratch-www)** also apply here. :-) 5 | 6 | In particular, although this code is used on the Scratch website, it's not maintained by the Scratch Team. So please remember developing this isn't our job! 7 | 8 | --- 9 | 10 | When **reporting an issue**, please do the following: 11 | 12 | * Read [the **syntax guide**](http://wiki.scratch.mit.edu/wiki/Block_Plugin/Syntax) 13 | * Use **code examples** and links to , where relevant 14 | * Provide **screenshots**/comparison with Scratch, where relevant 15 | 16 | --- 17 | 18 | For **pull requests**: 19 | 20 | * When developing, you'll want to run a local web server, eg. 21 | 22 | ``` 23 | python2 -m SimpleHTTPServer 8000 24 | ``` 25 | 26 | * Browse to to access the development version. 27 | 28 | * If you make a change in `src/defs.css`, run `make css` to update the JS file. 29 | 30 | * Before you send a PR, run `make` to check that the JS minifies correctly. 31 | 32 | To rebuild the translations (eg. to take into account new updates on Pootle), use `make translations`. 33 | 34 | To modify the homepage, send a PR to the [scratchblocks/scratchblocks.github.io](//github.com/scratchblocks/scratchblocks.github.io) repo. 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | node_modules 4 | *.pyc 5 | src/_cache 6 | build/ 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | scratchblocks is Copyright © 2013–2016, Tim Radvan 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | version := $(shell git describe --tags) 3 | all : css commands translations js 4 | 5 | clean : 6 | rm -r build 7 | rm src/translations.js 8 | rm src/translations-all.js 9 | 10 | js-name := build/scratchblocks-$(version)-min.js 11 | translations := build/translations-$(version)-min.js 12 | translations_all := build/translations-all-$(version)-min.js 13 | js : $(js-name) $(translations) $(translations_all) 14 | $(js-name) : \ 15 | src/scratchblocks.js 16 | mkdir -p build/ 17 | uglifyjs $^ > $@ --comments --mangle 18 | $(translations) : src/translations.js 19 | uglifyjs $^ > $@ --comments 20 | $(translations_all) : src/translations-all.js 21 | uglifyjs $^ > $@ --comments 22 | 23 | zopfli : 24 | zopfli build/*.js 25 | 26 | css : src/defs.css 27 | sed -i '' 's/var cssContent =.*/var cssContent = "$(shell cleancss $^)";/' \ 28 | src/scratchblocks.js 29 | 30 | commands : src/commands.js 31 | sh -c 'cd src ; python package_commands.py' 32 | 33 | translations : \ 34 | src/translations.js \ 35 | src/translations-all.js 36 | 37 | src/translations.js : src/extra_strings.py src/_cache src/commands.js src/build_translations.py 38 | sh -c 'cd src ; python build_translations.py' 39 | 40 | src/translations-all.js : src/extra_strings.py src/_cache src/commands.js src/build_translations.py 41 | sh -c 'cd src ; python build_translations.py all' 42 | 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Make pictures of Scratch blocks from text. 2 | 3 | [![Screenshot](http://scratchblocks.github.io/screenshot.png)](https://scratchblocks.github.io/#when%20flag%20clicked%0Aclear%0Aforever%0Apen%20down%0Aif%20%3C%3Cmouse%20down%3F%3E%20and%20%3Ctouching%20%5Bmouse-pointer%20v%5D%3F%3E%3E%20then%0Aswitch%20costume%20to%20%5Bbutton%20v%5D%0Aelse%0Aadd%20(x%20position)%20to%20%5Blist%20v%5D%0Aend%0Amove%20(foo)%20steps%0Aturn%20ccw%20(9)%20degrees) 4 | 5 | **[Try it out!](http://scratchblocks.github.io/)** 6 | 7 | --- 8 | 9 | **scratchblocks** is used to write Scratch scripts: 10 | 11 | - in [Scratch Forum](http://scratch.mit.edu/discuss/topic/14772/) posts 12 | - in [Scratch Wiki](http://wiki.scratch.mit.edu/wiki/Block_Plugin) articles 13 | - in the [Code Club](https://www.codeclub.org.uk) project guides 14 | 15 | It's MIT licensed, so you can use it in your projects. (But do send me a link 16 | [on Twitter](http://twitter.com/blob8108)!) 17 | 18 | For the full guide to the syntax, see [the wiki](http://wiki.scratch.mit.edu/wiki/Block_Plugin/Syntax). 19 | 20 | # Usage 21 | 22 | ## MediaWiki 23 | 24 | Use [the MediaWiki plugin](https://github.com/tjvr/wiki-scratchblocks). (This is what the [Scratch Wiki](http://wiki.scratch.mit.edu/wiki/Block_Plugin) uses.) 25 | 26 | ## WordPress 27 | 28 | I found [a WordPress plugin](https://github.com/tkc49/scratchblocks-for-wp). It might work for you; I haven't tried it. 29 | 30 | ## Pandoc 31 | 32 | Code Club use their own [lesson_format](https://github.com/CodeClub/lesson_format) tool to generate the PDF versions of their project guides. It uses the [pandoc_scratchblocks](https://github.com/CodeClub/pandoc_scratchblocks) plugin they wrote to make pictures of Scratch scripts. 33 | 34 | This would probably be a good way to write a Scratch book. 35 | 36 | ## Markdown 37 | 38 | By using [codeclub_lesson_builder](https://github.com/arve0/codeclub_lesson_builder) you can include scratch code directly in markdown codeblocks like this: 39 | 40 | ```blocks 41 | when flag clicked 42 | go to x:(-50) y:(0) 43 | ``` 44 | 45 | The markdown builds to HTML and PDF. 46 | 47 | ## HTML 48 | 49 | Include the scratchblocks JS file on your webpage: 50 | 51 | ```html 52 | 53 | ``` 54 | 55 | Then just call `scratchblocks.renderMatching` after the page has loaded, which 56 | will render matching page elements to shiny scratch blocks. Its sole argument 57 | is the CSS-style selector for the elements that contain the scratchblocks code. 58 | It uses `pre.blocks` by default. 59 | 60 | ```js 61 | scratchblocks.renderMatching("pre.blocks"); 62 | ``` 63 | 64 | Use `make`, or your preferred build tool, to minify the assets. You'll need to 65 | install some dependencies first: 66 | 67 | - Try `npm install` 68 | - Try `brew install zopfli`, or the equivalent command for your preferred package manager. 69 | 70 | See the [release notes](https://github.com/tjvr/scratchblocks/releases) for more details. 71 | 72 | ### Inline blocks 73 | 74 | To use blocks inside a paragraph... 75 | 76 | ```html 77 | I'm rather fond of the stamp block in Scratch. 78 | ``` 79 | 80 | ...make a separate call to `renderMatching` using the `inline` argument. 81 | 82 | ```js 83 | scratchblocks.renderMatching("code.b", {inline: true}); 84 | ``` 85 | 86 | # Languages 87 | 88 | [`translations.js`](https://github.com/tjvr/scratchblocks/blob/master/src/translations.js) contains all the languages needed [on the Scratch Forums](http://scratch.mit.edu/discuss/#category_head_6). 89 | 90 | `translations-all.js` contains all the languages Scratch supports. 91 | 92 | scratchblocks also requires some [additional words](https://github.com/tjvr/scratchblocks/blob/master/src/extra_strings.py) which aren't in Scratch itself (mainly the words used for the flag and arrow images). I'd be happy to accept pull requests for those! 93 | 94 | 95 | # Development 96 | 97 | See [`CONTRIBUTING.md`](https://github.com/tjvr/scratchblocks/blob/master/.github/CONTRIBUTING.md). 98 | 99 | 100 | # Credits 101 | 102 | Many, many thanks to the [contributors](https://github.com/tjvr/scratchblocks/graphs/contributors)! 103 | 104 | * Authored by [tjvr](https://github.com/tjvr) 105 | * SVG proof-of-concept, shapes & filters by [as-com](https://github.com/as-com) 106 | * Anna helped with a formula, and pointed out that I can't read graphs 107 | * JSO designed the syntax and wrote the original [Block Plugin](http://wiki.scratch.mit.edu/wiki/Block_Plugin_\(1.4\)) 108 | * Help with translation code from [joooni](http://scratch.mit.edu/users/joooni/) 109 | * Block translations from the [Scratch translation server](http://translate.scratch.mit.edu/) 110 | 111 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "scratchblocks", 3 | "version": "3.0.0", 4 | "description": "Render Scratch blocks code to SVG.", 5 | "directories": { 6 | "test": "tests" 7 | }, 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1", 10 | "build-make": "sh -c 'make all'", 11 | "build": "npm run build-make" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/tjvr/scratchblocks.git" 16 | }, 17 | "keywords": [ 18 | "scratch" 19 | ], 20 | "author": "tjvr", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/tjvr/scratchblocks/issues" 24 | }, 25 | "homepage": "https://scratchblocks.github.io/", 26 | "devDependencies": { 27 | "uglify-js": "^2.6.1", 28 | "clean-css": "^3.4.9" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/block_images/arrows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scratchfoundation/scratchblocks/e3a708aba2f385a7417a88eea5a5e8b8672ac5f6/src/block_images/arrows.png -------------------------------------------------------------------------------- /src/block_images/flag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scratchfoundation/scratchblocks/e3a708aba2f385a7417a88eea5a5e8b8672ac5f6/src/block_images/flag.png -------------------------------------------------------------------------------- /src/build_translations.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #coding=utf-8 3 | from __future__ import unicode_literals, division 4 | 5 | import codecs 6 | import json 7 | import os 8 | import re 9 | import sys 10 | from io import open # open -> str for both python 2.x and 3.x 11 | from copy import copy 12 | 13 | try: 14 | from urllib2 import HTTPError 15 | from urllib2 import urlopen 16 | except ImportError: 17 | from urllib.error import HTTPError 18 | from urllib.request import urlopen 19 | 20 | from extra_strings import extra_strings 21 | 22 | 23 | ALL_LANGS = ["ar", "an", "hy", "ast", "eu", "bn_IN", "nb", "bg", "zh_CN", 24 | "zh_TW", "da", "de", "eo", "et", "fo", "fi", "fr", "fr_CA", "gl", 25 | "ht", "he", "hi", "hch", "id", "ga", "is", "it", "ja", "ja_hr", 26 | "ja_HIRA", "km", "kn", "kk", "ca", "ko", "hr", "ku", "cy", "ky", 27 | "la", "lv", "lt", "mk", "ms", "ml", "mr", "maz", "mn", "my", 28 | "nah", "ne", "el", "nl", "no", "nn", "or", "os", "oto", "ote", 29 | "pap", "fa", "fil", "pl", "pt", "pt_BR", "ro", "ru", "rw", "sv", 30 | "sr", "sk", "sl", "es", "sw", "tzm", "ta", "th", "cs", "tr", "ug", 31 | "uk", "hu", "vi"] 32 | 33 | BLACKLIST = set(["or"]) 34 | 35 | # ISO Codes for all the language forums. 36 | FORUM_LANGS = ['de', 'es', 'fr', 'zh_CN', 'pl', 'ja', 'nl' , 'pt', 'it', 37 | 'he', 'ko', 'nb', 'tr', 'el', 'ru', 'ca', 'id'] 38 | 39 | langs = "forum" 40 | if len(sys.argv) > 1: 41 | if sys.argv[1] == "--help": 42 | print("\nA tool for combining and packaging scratch translations.") 43 | print("\n Usage: python build_translations.py [--help] [all]") 44 | exit() 45 | if sys.argv[1] == "all": 46 | langs = "all" 47 | 48 | if langs == "all": 49 | LANGUAGES = ALL_LANGS 50 | else: 51 | LANGUAGES = FORUM_LANGS 52 | 53 | INSERT_RE = re.compile(r'(%[A-Za-z](?:\.[A-Za-z]+)?)') 54 | PICTURE_RE = re.compile(r'@[A-Za-z-]+') 55 | JUNK_RE = re.compile(r'[ \t,\%?:]') 56 | 57 | def parse_po(content): 58 | msg_id = None 59 | translations = {} 60 | for line in content.split("\n"): 61 | if line.startswith("msgid "): 62 | msg_id = line[6:].strip().strip('"') 63 | elif line.startswith("msgstr "): 64 | msg_str = line[7:].strip().strip('"') 65 | if msg_str and msg_id is not None: 66 | translations[msg_id] = msg_str 67 | msg_id = None 68 | return translations 69 | 70 | def fetch_po(lang, project): 71 | filename = os.path.join("_cache", "{lang}-{project}.po".format(**vars())) 72 | if not os.path.exists("_cache"): 73 | os.mkdir("_cache") 74 | if os.path.exists(filename): 75 | return open(filename, encoding='utf-8').read() 76 | name = (lang if project == "scratch1.4" else project) 77 | url = "http://translate.scratch.mit.edu/download/{lang}/{proj}/{name}.po" 78 | url = url.format(proj=project, **vars()) 79 | print("GETing {url}".format(**vars())) 80 | try: 81 | data = urlopen(url).read().decode('utf-8') 82 | open(filename, "w", encoding="utf-8").write(data) 83 | return data 84 | except HTTPError as e: 85 | if e.code == 404: 86 | print("HTTP 404 not found:", url) 87 | return "" 88 | raise 89 | 90 | all_languages = {} 91 | 92 | # Get spec list from JS 93 | english_commands = json.loads('{"commands":' + open('commands.js').read().rstrip(";\n],") + ']]}')["commands"] 94 | command_specs = [c[0] for c in english_commands] 95 | 96 | # Prepare blocks lists 97 | untranslated = set([ 98 | "%n + %n", 99 | "%n - %n", 100 | "%n * %n", 101 | "%n / %n", 102 | "%s < %s", 103 | "%s = %s", 104 | "%s > %s", 105 | "…", 106 | "..." 107 | ]) 108 | acceptable_missing = set([ 109 | "username", 110 | ]) 111 | need_aliases = [ 112 | "turn @turnRight %n degrees", 113 | "turn @turnLeft %n degrees", 114 | "when @greenFlag clicked", 115 | ] 116 | 117 | math_funcs = ["abs", "floor", "ceiling", "sqrt", "sin", "cos", "tan", "asin", "acos", "atan", "ln", "log", "e ^", "10 ^"] 118 | osis = ["other scripts in sprite", "other scripts in stage"] 119 | 120 | dropdown_values = ["A connected", "all", "all around", "all motors", 121 | "B connected", "brightness", "button pressed", "C connected", "color", 122 | "costume name", "D connected", "date", "day of week", "don't rotate", 123 | "down arrow", "edge", "everything", "fisheye", "ghost", "hour", 124 | "left arrow", "left-right", "light", "lights", "minute", "month", 125 | "mosaic", "motion", "motor", "motor A", "motor B", "mouse-pointer", 126 | "myself", "not =", "off", "on", "on-flipped", "other scripts in sprite", 127 | "pixelate", "previous backdrop", "random position", "resistance-A", 128 | "resistance-B", "resistance-C", "resistance-D", "reverse", "right arrow", 129 | "second", "slider", "sound", "space", "Stage", "that way", "this script", 130 | "this sprite", "this way", "up arrow", "video motion", "whirl", "year", 131 | ] 132 | 133 | def nonempty(seq): 134 | return list(set(filter(None, seq))) 135 | 136 | for lang in LANGUAGES: 137 | if lang in BLACKLIST: continue 138 | print(lang) 139 | 140 | lang_blocks = parse_po(fetch_po(lang, "blocks")) 141 | lang_editor = parse_po(fetch_po(lang, "editor")) 142 | extra_aliases = extra_strings.get(lang, {}).copy() 143 | 144 | when_distance = None 145 | if " < %n" in lang_blocks.get("when distance < %n", ""): 146 | when_distance, _ = lang_blocks["when distance < %n"].split(" < %n") 147 | 148 | end_block = None 149 | for translated_text, english_spec in copy(extra_aliases).items(): 150 | if english_spec == "end": 151 | end_block = translated_text 152 | del extra_aliases[translated_text] 153 | 154 | for english_spec in need_aliases: 155 | if english_spec not in extra_aliases.values(): 156 | print("%s is missing alias: %s" % (lang, english_spec)) 157 | 158 | count = 0 159 | commands = {} 160 | for spec in command_specs: 161 | if spec == "end": 162 | lang_spec = end_block or "" 163 | else: 164 | lang_spec = (lang_blocks.get(spec) 165 | or lang_blocks.get(spec.replace("%m.location", "%m.spriteOrMouse")) 166 | ) 167 | if lang_spec: 168 | commands[spec] = lang_spec 169 | count += 1 170 | else: 171 | if spec == "end": 172 | print("%s is missing extra: end" % lang) 173 | elif spec not in untranslated and spec not in acceptable_missing: 174 | print("%s is missing: %s" % (lang, spec)) 175 | print("{}: {:.1f}%".format(lang, count/len(command_specs)*100)) 176 | 177 | dropdowns = {} 178 | for name in dropdown_values: 179 | native_name = lang_blocks.get(name) or lang_editor.get(name, '') 180 | if native_name: 181 | dropdowns[name] = native_name 182 | 183 | palette = dict((x, lang_blocks.get(x) or lang_editor.get(x)) for x in [ 184 | "Motion", "Looks", "Sound", "Pen", "Data", "variables", "variable", 185 | "lists", "list", "Events", "Control", "Sensing", "Operators", 186 | "More Blocks", 187 | ]) 188 | palette['Tips'] = lang_editor.get('Tips') 189 | 190 | language = { 191 | 'aliases': extra_aliases, 192 | 'define': [lang_blocks.get('define', '')], 193 | 'ignorelt': [when_distance], 194 | 'math': nonempty(map(lang_editor.get, math_funcs)), 195 | 'osis': nonempty(map(lang_editor.get, osis)), 196 | 'commands': commands, 197 | 'dropdowns': dropdowns, # for translate() 198 | 'palette': palette, # for scratchblocks menu 199 | } 200 | all_languages[lang] = language 201 | 202 | block_ids = [] 203 | some_language_translations = list(all_languages.values())[0] 204 | for bid in some_language_translations.keys(): 205 | if not bid[0].isupper(): # Assume upper-case are category names 206 | block_ids.append(bid) 207 | 208 | translations_array = [] 209 | translations_array.append([None] + block_ids) 210 | for lang, translations in all_languages.items(): 211 | language_array = [lang] 212 | for bid in block_ids: 213 | if bid not in translations: 214 | print("%s doesn't have %s" % (lang, bid)) 215 | language_array.append(translations.get(bid, '')) 216 | translations_array.append(language_array) 217 | 218 | #open("blocks-%s.js" % lang, "w").write(json.dumps(language_array, 219 | # ensure_ascii=False)) 220 | 221 | encoded = json.dumps(all_languages, ensure_ascii=False, indent=2) 222 | data = "scratchblocks.loadLanguages({});".format(encoded) 223 | if langs == 'all': 224 | filename = "translations-all.js" 225 | else: 226 | filename = "translations.js" 227 | open(filename, "wb").write(data.encode("utf-8")) 228 | print("Wrote %s" % filename) 229 | -------------------------------------------------------------------------------- /src/commands.js: -------------------------------------------------------------------------------- 1 | [ 2 | 3 | ["move %n steps", " ", 1, "forward:"], 4 | ["turn @turnRight %n degrees", " ", 1, "turnRight:"], 5 | ["turn @turnLeft %n degrees", " ", 1, "turnLeft:"], 6 | ["point in direction %d.direction", " ", 1, "heading:"], 7 | ["point towards %m.spriteOrMouse", " ", 1, "pointTowards:"], 8 | ["go to x:%n y:%n", " ", 1, "gotoX:y:"], 9 | ["go to %m.location", " ", 1, "gotoSpriteOrMouse:"], 10 | ["glide %n secs to x:%n y:%n", " ", 1, "glideSecs:toX:y:elapsed:from:"], 11 | ["change x by %n", " ", 1, "changeXposBy:"], 12 | ["set x to %n", " ", 1, "xpos:"], 13 | ["change y by %n", " ", 1, "changeYposBy:"], 14 | ["set y to %n", " ", 1, "ypos:"], 15 | ["set rotation style %m.rotationStyle", " ", 1, "setRotationStyle"], 16 | ["say %s for %n secs", " ", 2, "say:duration:elapsed:from:"], 17 | ["say %s", " ", 2, "say:"], 18 | ["think %s for %n secs", " ", 2, "think:duration:elapsed:from:"], 19 | ["think %s", " ", 2, "think:"], 20 | ["show", " ", 2, "show"], 21 | ["hide", " ", 2, "hide"], 22 | ["switch costume to %m.costume", " ", 2, "lookLike:"], 23 | ["next costume", " ", 2, "nextCostume"], 24 | ["next backdrop", " ", 102, "nextScene"], 25 | ["switch backdrop to %m.backdrop", " ", 2, "startScene"], 26 | ["switch backdrop to %m.backdrop and wait", " ", 102, "startSceneAndWait"], 27 | ["change %m.effect effect by %n", " ", 2, "changeGraphicEffect:by:"], 28 | ["set %m.effect effect to %n", " ", 2, "setGraphicEffect:to:"], 29 | ["clear graphic effects", " ", 2, "filterReset"], 30 | ["change size by %n", " ", 2, "changeSizeBy:"], 31 | ["set size to %n%", " ", 2, "setSizeTo:"], 32 | ["go to front", " ", 2, "comeToFront"], 33 | ["go back %n layers", " ", 2, "goBackByLayers:"], 34 | ["play sound %m.sound", " ", 3, "playSound:"], 35 | ["play sound %m.sound until done", " ", 3, "doPlaySoundAndWait"], 36 | ["stop all sounds", " ", 3, "stopAllSounds"], 37 | ["play drum %d.drum for %n beats", " ", 3, "playDrum"], 38 | ["rest for %n beats", " ", 3, "rest:elapsed:from:"], 39 | ["play note %d.note for %n beats", " ", 3, "noteOn:duration:elapsed:from:"], 40 | ["set instrument to %d.instrument", " ", 3, "instrument:"], 41 | ["change volume by %n", " ", 3, "changeVolumeBy:"], 42 | ["set volume to %n%", " ", 3, "setVolumeTo:"], 43 | ["change tempo by %n", " ", 3, "changeTempoBy:"], 44 | ["set tempo to %n bpm", " ", 3, "setTempoTo:"], 45 | ["clear", " ", 4, "clearPenTrails"], 46 | ["stamp", " ", 4, "stampCostume"], 47 | ["pen down", " ", 4, "putPenDown"], 48 | ["pen up", " ", 4, "putPenUp"], 49 | ["set pen color to %c", " ", 4, "penColor:"], 50 | ["change pen color by %n", " ", 4, "changePenHueBy:"], 51 | ["set pen color to %n", " ", 4, "setPenHueTo:"], 52 | ["change pen shade by %n", " ", 4, "changePenShadeBy:"], 53 | ["set pen shade to %n", " ", 4, "setPenShadeTo:"], 54 | ["change pen size by %n", " ", 4, "changePenSizeBy:"], 55 | ["set pen size to %n", " ", 4, "penSize:"], 56 | ["when @greenFlag clicked", "h", 5, "whenGreenFlag"], 57 | ["when %m.key key pressed", "h", 5, "whenKeyPressed"], 58 | ["when this sprite clicked", "h", 5, "whenClicked"], 59 | ["when backdrop switches to %m.backdrop", "h", 5, "whenSceneStarts"], 60 | ["when %m.triggerSensor > %n", "h", 5, "whenSensorGreaterThan"], 61 | ["when I receive %m.broadcast", "h", 5, "whenIReceive"], 62 | ["broadcast %m.broadcast", " ", 5, "broadcast:"], 63 | ["broadcast %m.broadcast and wait", " ", 5, "doBroadcastAndWait"], 64 | ["wait %n secs", " ", 6, "wait:elapsed:from:"], 65 | ["repeat %n", "c", 6, "doRepeat"], 66 | ["forever", "cf",6, "doForever"], 67 | ["if %b then", "c", 6, "doIf"], 68 | ["if %b then", "e", 6, "doIfElse"], 69 | ["wait until %b", " ", 6, "doWaitUntil"], 70 | ["repeat until %b", "c", 6, "doUntil"], 71 | ["stop %m.stop", "f", 6, "stopScripts"], 72 | ["when I start as a clone", "h", 6, "whenCloned"], 73 | ["create clone of %m.spriteOnly", " ", 6, "createCloneOf"], 74 | ["delete this clone", "f", 6, "deleteClone"], 75 | ["ask %s and wait", " ", 7, "doAsk"], 76 | ["turn video %m.videoState", " ", 7, "setVideoState"], 77 | ["set video transparency to %n%", " ", 7, "setVideoTransparency"], 78 | ["reset timer", " ", 7, "timerReset"], 79 | ["set %m.var to %s", " ", 9, "setVar:to:"], 80 | ["change %m.var by %n", " ", 9, "changeVar:by:"], 81 | ["show variable %m.var", " ", 9, "showVariable:"], 82 | ["hide variable %m.var", " ", 9, "hideVariable:"], 83 | ["add %s to %m.list", " ", 12, "append:toList:"], 84 | ["delete %d.listDeleteItem of %m.list", " ", 12, "deleteLine:ofList:"], 85 | ["if on edge, bounce", " ", 1, "bounceOffEdge"], 86 | ["insert %s at %d.listItem of %m.list", " ", 12, "insert:at:ofList:"], 87 | ["replace item %d.listItem of %m.list with %s", " ", 12, "setLine:ofList:to:"], 88 | ["show list %m.list", " ", 12, "showList:"], 89 | ["hide list %m.list", " ", 12, "hideList:"], 90 | 91 | ["x position", "r", 1, "xpos"], 92 | ["y position", "r", 1, "ypos"], 93 | ["direction", "r", 1, "heading"], 94 | ["costume #", "r", 2, "costumeIndex"], 95 | ["size", "r", 2, "scale"], 96 | ["backdrop name", "r", 102, "sceneName"], 97 | ["backdrop #", "r", 102, "backgroundIndex"], 98 | ["volume", "r", 3, "volume"], 99 | ["tempo", "r", 3, "tempo"], 100 | ["touching %m.touching?", "b", 7, "touching:"], 101 | ["touching color %c?", "b", 7, "touchingColor:"], 102 | ["color %c is touching %c?", "b", 7, "color:sees:"], 103 | ["distance to %m.spriteOrMouse", "r", 7, "distanceTo:"], 104 | ["answer", "r", 7, "answer"], 105 | ["key %m.key pressed?", "b", 7, "keyPressed:"], 106 | ["mouse down?", "b", 7, "mousePressed"], 107 | ["mouse x", "r", 7, "mouseX"], 108 | ["mouse y", "r", 7, "mouseY"], 109 | ["loudness", "r", 7, "soundLevel"], 110 | ["video %m.videoMotionType on %m.stageOrThis", "r", 7, "senseVideoMotion"], 111 | ["timer", "r", 7, "timer"], 112 | ["%m.attribute of %m.spriteOrStage", "r", 7, "getAttribute:of:"], 113 | ["current %m.timeAndDate", "r", 7, "timeAndDate"], 114 | ["days since 2000", "r", 7, "timestamp"], 115 | ["username", "r", 7, "getUserName"], 116 | ["%n + %n", "r", 8, "+"], 117 | ["%n - %n", "r", 8, "-"], 118 | ["%n * %n", "r", 8, "*"], 119 | ["%n / %n", "r", 8, "/"], 120 | ["pick random %n to %n", "r", 8, "randomFrom:to:"], 121 | ["%s < %s", "b", 8, "<"], 122 | ["%s = %s", "b", 8, "="], 123 | ["%s > %s", "b", 8, ">"], 124 | ["%b and %b", "b", 8, "&"], 125 | ["%b or %b", "b", 8, "|"], 126 | ["not %b", "b", 8, "not"], 127 | ["join %s %s", "r", 8, "concatenate:with:"], 128 | ["letter %n of %s", "r", 8, "letter:of:"], 129 | ["length of %s", "r", 8, "stringLength:"], 130 | ["%n mod %n", "r", 8, "%"], 131 | ["round %n", "r", 8, "rounded"], 132 | ["%m.mathOp of %n", "r", 8, "computeFunction:of:"], 133 | ["item %d.listItem of %m.list", "r", 12, "getLine:ofList:"], 134 | ["length of %m.list", "r", 12, "lineCountOfList:"], 135 | ["%m.list contains %s?", "b", 12, "list:contains:"], 136 | 137 | ["when %m.booleanSensor", "h", 20, ""], 138 | ["when %m.sensor %m.lessMore %n", "h", 20, ""], 139 | ["sensor %m.booleanSensor?", "b", 20, ""], 140 | ["%m.sensor sensor value", "r", 20, ""], 141 | 142 | ["turn %m.motor on for %n secs", " ", 20, ""], 143 | ["turn %m.motor on", " ", 20, ""], 144 | ["turn %m.motor off", " ", 20, ""], 145 | ["set %m.motor power to %n", " ", 20, ""], 146 | ["set %m.motor2 direction to %m.motorDirection", " ", 20, ""], 147 | ["when distance %m.lessMore %n", "h", 20, ""], 148 | ["when tilt %m.eNe %n", "h", 20, ""], 149 | ["distance", "r", 20, ""], 150 | ["tilt", "r", 20, ""], 151 | 152 | ["turn %m.motor on for %n seconds", " ", 20, ""], 153 | ["set light color to %n", " ", 20, ""], 154 | ["play note %n for %n seconds", " ", 20, ""], 155 | ["when tilted", "h", 20, ""], 156 | ["tilt %m.xxx", "r", 20, ""], 157 | 158 | ["else", "else", 6, ""], 159 | ["end", "end", 6, ""], 160 | [". . .", " ", 42, ""], 161 | 162 | ["%n @addInput", "ring", 42, ""], 163 | 164 | ["user id", "r", 0, ""], 165 | 166 | ["if %b", "c", 0, "doIf"], 167 | ["if %b", "e", 0, "doIfElse"], 168 | ["forever if %b", "cf", 0, "doForeverIf"], 169 | ["stop script", "f", 0, "doReturn"], 170 | ["stop all", "f", 0, "stopAll"], 171 | ["switch to costume %m.costume", " ", 0, "lookLike:"], 172 | ["next background", " ", 0, "nextScene"], 173 | ["switch to background %m.backdrop", " ", 0, "startScene"], 174 | ["background #", "r", 0, "backgroundIndex"], 175 | ["loud?", "b", 0, "isLoud"], 176 | 177 | ]; 178 | -------------------------------------------------------------------------------- /src/defs.css: -------------------------------------------------------------------------------- 1 | 2 | .sb-label { 3 | font-family: Lucida Grande, Verdana, Arial, DejaVu Sans, sans-serif; 4 | font-weight: bold; 5 | fill: #fff; 6 | font-size: 10px; 7 | word-spacing: +1px; 8 | } 9 | 10 | .sb-obsolete { fill: #d42828; } 11 | .sb-motion { fill: #4a6cd4; } 12 | .sb-looks { fill: #8a55d7; } 13 | .sb-sound { fill: #bb42c3; } 14 | .sb-pen { fill: #0e9a6c; } 15 | .sb-events { fill: #c88330; } 16 | .sb-control { fill: #e1a91a; } 17 | .sb-sensing { fill: #2ca5e2; } 18 | .sb-operators { fill: #5cb712; } 19 | .sb-variables { fill: #ee7d16; } 20 | .sb-list { fill: #cc5b22 } 21 | .sb-custom { fill: #632d99; } 22 | .sb-custom-arg { fill: #5947b1; } 23 | .sb-extension { fill: #4b4a60; } 24 | .sb-grey { fill: #969696; } 25 | 26 | .sb-bevel { 27 | filter: url(#bevelFilter); 28 | } 29 | 30 | .sb-input { 31 | filter: url(#inputBevelFilter); 32 | } 33 | .sb-input-number, 34 | .sb-input-string, 35 | .sb-input-number-dropdown { 36 | fill: #fff; 37 | } 38 | .sb-literal-number, 39 | .sb-literal-string, 40 | .sb-literal-number-dropdown, 41 | .sb-literal-dropdown { 42 | font-weight: normal; 43 | font-size: 9px; 44 | word-spacing: 0; 45 | } 46 | .sb-literal-number, 47 | .sb-literal-string, 48 | .sb-literal-number-dropdown { 49 | fill: #000; 50 | } 51 | 52 | .sb-darker { 53 | filter: url(#inputDarkFilter); 54 | } 55 | 56 | .sb-outline { 57 | stroke: #fff; 58 | stroke-opacity: 0.2; 59 | stroke-width: 2; 60 | fill: none; 61 | } 62 | 63 | .sb-define-hat-cap { 64 | stroke: #632d99; 65 | stroke-width: 1; 66 | fill: #8e2ec2; 67 | } 68 | 69 | .sb-comment { 70 | fill: #ffffa5; 71 | stroke: #d0d1d2; 72 | stroke-width: 1; 73 | } 74 | .sb-comment-line { 75 | fill: #ffff80; 76 | } 77 | .sb-comment-label { 78 | font-family: Helevetica, Arial, DejaVu Sans, sans-serif; 79 | font-weight: bold; 80 | fill: #5c5d5f; 81 | word-spacing: 0; 82 | font-size: 12px; 83 | } 84 | 85 | -------------------------------------------------------------------------------- /src/dev.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | dev : [scratchblocks] 5 | 6 | 16 | 17 | 76 | 77 | 78 | 79 |

[scratchblocks]: dev

80 | 81 |

You need to serve this page from a local web server.

82 | 83 | 84 | 85 |
86 | 87 | 88 | 108 | 109 | (* = language is missing some blocks, 110 | † = language doesn't have Scratch 1.4 blocks) 111 |
112 | 113 |

114 | 
115 | 
116 | 
117 | 
118 | 
119 | 
180 | 


--------------------------------------------------------------------------------
/src/extra_strings.py:
--------------------------------------------------------------------------------
  1 | # coding=utf-8
  2 | from __future__ import unicode_literals
  3 | 
  4 | """
  5 | We need extra translations for the following strings that aren't included on
  6 | translate.scratch.mit.edu:
  7 |  
  8 |  - "turn left 10 degrees"
  9 |  - "turn right 10 degrees"
 10 |  - "when green flag clicked"
 11 |  - "end" (written after a "C" block)
 12 | 
 13 | """
 14 | 
 15 | extra_strings = {
 16 | 
 17 |     "de": { # German
 18 |         "drehe dich nach links um %n Grad": "turn @turnLeft %n degrees",
 19 |         "drehe dich nach rechts um %n Grad": "turn @turnRight %n degrees",
 20 |         "Wenn die grüne Flagge angeklickt": "when @greenFlag clicked",
 21 |         "Ende": "end",
 22 |     },
 23 | 
 24 |     "pt": { # Portugese
 25 |         "gira para a esquerda %n º": "turn @turnLeft %n degrees",
 26 |         "gira para a direita %n º": "turn @turnRight %n degrees",
 27 |         "Quando alguém clicar na bandeira verde": "when @greenFlag clicked",
 28 |         "fim": "end",
 29 |     },
 30 | 
 31 |     "it": { # Italian
 32 |         "ruota in senso antiorario di %n gradi": "turn @turnLeft %n degrees",
 33 |         "ruota in senso orario di %n gradi": "turn @turnRight %n degrees",
 34 |         "quando si clicca sulla bandiera verde": "when @greenFlag clicked",
 35 |         "fine": "end",
 36 |     },
 37 | 
 38 |     "fr": { # French
 39 |         "tourner gauche de %n degrés": "turn @turnLeft %n degrees",
 40 |         "tourner droite de %n degrés": "turn @turnRight %n degrees",
 41 |         "quand le drapeau vert pressé": "when @greenFlag clicked",
 42 |         "fin": "end",
 43 |     },
 44 | 
 45 |     "es": { # Spanish
 46 |         "girar a la izquierda %n grados": "turn @turnLeft %n degrees",
 47 |         "girar a la derecha %n grados": "turn @turnRight %n degrees",
 48 |         "al presionar bandera verde": "when @greenFlag clicked",
 49 |         "fin": "end",
 50 |     },
 51 | 
 52 |     "nl": { # Dutch
 53 |         "draai %n graden naar links": "turn @turnLeft %n degrees",
 54 |         "draai %n graden naar rechts": "turn @turnRight %n degrees",
 55 |         "wanneer groene vlag wordt aangeklikt": "when @greenFlag clicked",
 56 |         "einde": "end",
 57 |     },
 58 | 
 59 |     "zh_CN": { # Chinese (simplified)
 60 |         "左转 %n 度": "turn @turnLeft %n degrees",
 61 |         "右转 %n 度": "turn @turnRight %n degrees",
 62 |         "转动CCW %n 度": "turn @turnLeft %n degrees",
 63 |         "转动CW %n 度": "turn @turnRight %n degrees",
 64 |         "点击绿旗时": "when @greenFlag clicked",
 65 |         "结束": "end",
 66 |     },
 67 | 
 68 |     "he": { # Hebrew
 69 |         "הסתובב שמאל %n מעלות": "turn @turnLeft %n degrees",
 70 |         "הסתובב ימינה %n מעלות": "turn @turnRight %n degrees",
 71 |         "כאשר לוחצים על דגל ירוק": "when @greenFlag clicked",
 72 |         "סוף": "end",
 73 |     },
 74 | 
 75 |     "pl": { # Polish
 76 |         "obróć w lewo o %n stopni": "turn @turnLeft %n degrees",
 77 |         "obróć w prawo o %n stopni": "turn @turnRight %n degrees",
 78 |         "kiedy kliknięto zieloną flagę": "when @greenFlag clicked",
 79 |         "koniec": "end",
 80 |     },
 81 | 
 82 |     "nb": { # Norwegian
 83 |         "vend venstre %n grader": "turn @turnLeft %n degrees",
 84 |         "vend høyre %n grader": "turn @turnRight %n degrees",
 85 |         "når grønt flagg klikkes": "when @greenFlag clicked",
 86 |         "slutt": "end",
 87 |     },
 88 | 
 89 |     "ru": { # Russian
 90 |         "повернуть влево на %n градусов": "turn @turnLeft %n degrees",
 91 |         "повернуть вправо на %n градусов": "turn @turnRight %n degrees",
 92 |         "когда щёлкнут по зелёному флагу": "when @greenFlag clicked",
 93 |         "конец": "end",
 94 |     },
 95 | 
 96 |     "ca": { # Catalan
 97 |         "gira a l'esquerra %n graus": "turn @turnLeft %n degrees",
 98 |         "gira a la dreta %n graus": "turn @turnRight %n degrees",
 99 |         "quan la bandera verda es premi": "when @greenFlag clicked",
100 |         "fi": "end",
101 |     },
102 | 
103 |     "tr": { # Turkish
104 |         "_ derece sola dön": "turn @turnLeft %n degrees",
105 |         "_ derece sağa dön": "turn @turnRight %n degrees",
106 |         "_ derece saatin tersi yönde dön": "turn @turnLeft %n degrees",
107 |         "_ derece saat yönünde dön": "turn @turnRight %n degrees",
108 |         "yeşil bayrak tıklandığında": "when @greenFlag clicked",
109 |         "son": "end",
110 |     },
111 | 
112 |     "el": { # Greek
113 |         "στρίψε αριστερά %n μοίρες": "turn @turnLeft %n degrees",
114 |         "στρίψε αριστερόστροφα %n μοίρες": "turn @turnLeft %n degrees",
115 |         "στρίψε δεξιά %n μοίρες": "turn @turnRight %n degrees",
116 |         "στρίψε δεξιόστροφα %n μοίρες": "turn @turnRight %n degrees",
117 |         "Όταν στην πράσινη σημαία γίνει κλικ": "when @greenFlag clicked",
118 |         "τέλος": "end",
119 |     },
120 | 
121 |     "": { # template
122 |         "": "turn @turnLeft %n degrees",
123 |         "": "turn @turnRight %n degrees",
124 |         "": "when @greenFlag clicked",
125 |         "": "end",
126 |     },
127 | 
128 | }
129 | 
130 | 


--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
  1 | 
  2 | 
  3 | 
  4 | scratchblocks dev
  5 | 
  6 | 
  7 | 
  8 | 
 11 | 
 12 | 
 13 | 
 39 | 
 40 | 
 41 | 
 42 | 

43 | scratchblocks dev 44 | 45 | help 46 | github 47 | generate 48 | 49 |

50 | 51 |
52 |
53 | 138 | 139 | 140 | 141 |
142 | 143 | 144 |
145 | 146 |

147 | 
148 | 
149 | 
150 | 
151 | 
152 | 
153 | 
343 | 
344 | 
353 | 
354 | 


--------------------------------------------------------------------------------
/src/inline-dev.html:
--------------------------------------------------------------------------------
  1 | 
  2 | 
  3 | 
  4 | inline dev : [scratchblocks]
  5 | 
  6 | 
  7 | 
  8 | 
 68 | 
 69 | 
 70 | 
 71 | 

[scratchblocks]: dev

72 | 73 |

You need to serve this page from a local web server.

74 | 75 | 76 | 77 | 78 | 79 | This is a sentence preceding the most interesting statement in this paragraph. 80 | This paragraph contains a block, oh yes 81 | it does. I'm very fond of this block; it's always been my friend. 82 | 83 | 134 | -------------------------------------------------------------------------------- /src/lib/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | 5 | body, div, p, textarea, pre { 6 | margin: 0; 7 | padding: 0; 8 | line-height: 1.5em; 9 | font: inherit; 10 | } 11 | 12 | body { 13 | font-size: 1em; 14 | padding: 1em; 15 | margin: 0 auto; 16 | max-width: 60em; 17 | 18 | background: white; 19 | color: black; 20 | } 21 | 22 | body, .CodeMirror { 23 | font-family: Noto Sans, sans-serif; 24 | } 25 | 26 | select, input, button { 27 | font: inherit; 28 | font-size: 1em; 29 | } 30 | 31 | input { 32 | border: 1px solid #ccc; 33 | max-width: 100%; 34 | } 35 | 36 | h1, h2, code, input[type=url], #num-chosen-scripts { 37 | font-family: Noto Sans, sans-serif; 38 | } 39 | 40 | h1 { 41 | font-weight: 700; 42 | font-size: 1.5em; 43 | } 44 | 45 | h1 span { 46 | font-weight: 400; 47 | font-size: 1.125rem; 48 | letter-spacing: 0; 49 | } 50 | 51 | h1 span a { 52 | margin-right: 0.5em; 53 | } 54 | 55 | h1 span a b { 56 | font-weight: 600; 57 | } 58 | 59 | a#title { 60 | background: none; 61 | margin-right: 0.5em; 62 | } 63 | 64 | a { 65 | color: black; 66 | text-decoration: none; 67 | background: #fffccc; 68 | cursor: pointer; 69 | } 70 | a:hover { 71 | border-bottom: 0.1em solid; 72 | cursor: pointer; 73 | background: #fffc7d; 74 | } 75 | a:active { 76 | opacity: 0.4; 77 | } 78 | 79 | p { 80 | margin: 0 0 1.5rem; 81 | line-height: 1.5em; 82 | } 83 | 84 | p a { 85 | background: none; 86 | border-bottom: 0.08em #aaa solid; 87 | border-radius: 0; 88 | padding: 0; 89 | top: 0; 90 | -webkit-transition: top 200ms ease-in; 91 | position: relative; 92 | } 93 | p a:visited { 94 | color: #aaa; 95 | } 96 | p a:hover, p a:visited:hover { 97 | background: none; 98 | color: #006ed8; 99 | border-bottom-color: #006ed8; 100 | -webkit-transition: color 100ms linear, border-bottom-color 100ms linear; 101 | } 102 | p a:active { 103 | top: 0.05em; 104 | -webkit-transition: none; 105 | opacity: 1; 106 | } 107 | 108 | 109 | 110 | 111 | 112 | label { 113 | font-weight: bold; 114 | cursor: pointer; 115 | } 116 | 117 | button, .button { 118 | display: inline-block; 119 | font-size: 1.25em; 120 | margin-bottom: 1em; 121 | padding: 2px 4px; 122 | color: black; 123 | 124 | font-weight: 500; 125 | position: relative; 126 | top: -2px; 127 | left: -2px; 128 | vertical-align: middle; 129 | /*-webkit-appearance: none; 130 | outline: none;*/ 131 | -webkit-transition: none; 132 | } 133 | button, .button, button:hover, .button:hover, .button:visited { 134 | background: #f0f0f0; 135 | border: 1px solid #aaa; 136 | border-bottom-width: 3px; 137 | cursor: default; 138 | color: black; 139 | -webkit-transition: none; 140 | } 141 | button:focus, .button:focus { 142 | /*box-shadow: 0 0 1px rgba(0, 0, 255, 0.5);*/ 143 | } 144 | button:active, button.pressed, .button:active, .button.pressed { 145 | border-bottom-width: 1px; 146 | border-top-width: 2px; 147 | background: #e0e0e0; 148 | baseline: 2px; 149 | color: black; 150 | opacity: 1; 151 | } 152 | 153 | 154 | 155 | 156 | /* editor */ 157 | 158 | #lang-status { 159 | font-size: 0.6rem; 160 | line-height: 1em; 161 | } 162 | 163 | #editor { 164 | position: relative; 165 | overflow: hidden; 166 | margin: 1em 0; 167 | border: 1px solid #bbb; 168 | max-width: 40em; 169 | height: 16em; 170 | width: 100%; 171 | 172 | color: rgba(0, 0, 0, 0.9); 173 | } 174 | 175 | .CodeMirror { 176 | letter-spacing: +0.5px; 177 | line-height: 1.5em; 178 | font-size: 1em; 179 | } 180 | 181 | .CodeMirror .CodeMirror-placeholder { 182 | color: #aaa; 183 | } 184 | 185 | .CodeMirror-linenumber { 186 | font-size: 0.85rem; 187 | line-height: 1.5rem; 188 | min-width: 17px; 189 | } 190 | 191 | .sb2 { 192 | margin: 0; 193 | margin-bottom: 20px; 194 | } 195 | 196 | #preview { 197 | position: relative; 198 | } 199 | 200 | .export-link { 201 | display: inline-block; 202 | margin-left: 2px; 203 | margin-top: 2em; 204 | margin-right: 1em; 205 | } 206 | 207 | 208 | @media screen and (min-width: 62em) { 209 | body { 210 | padding: 1em 2em; 211 | max-width: none; 212 | } 213 | 214 | h1 { 215 | position: relative; 216 | } 217 | h1 span { 218 | display: block; 219 | position: absolute; 220 | top: 0; 221 | left: 45%; 222 | margin-left: 2rem; 223 | } 224 | 225 | #preview, #side { 226 | position: absolute; 227 | bottom: 2em; left: 2em; right: 2em; 228 | } 229 | 230 | #editor { 231 | position: absolute; 232 | top: 3.25em; bottom: 0; left: 2em; right: 0; 233 | margin: 0; 234 | height: auto; 235 | } 236 | 237 | #side { 238 | top: 4.75em; 239 | left: 45%; 240 | padding-left: 2em; 241 | } 242 | 243 | #preview { 244 | top: 8em; 245 | right: 55%; 246 | } 247 | 248 | .export-link { 249 | margin-top: 0; 250 | margin-left: 0; 251 | margin-right: 0.5em; 252 | } 253 | } 254 | 255 | @media screen and (max-width: 32em) { 256 | h1 span { 257 | display: block; 258 | margin: 1.5rem 0 1rem; 259 | } 260 | h1 span a { 261 | padding: 0.25em 0.5em; 262 | } 263 | 264 | select { 265 | margin: 1rem 0; 266 | } 267 | } 268 | 269 | 270 | 271 | /* editor: to be used in future */ 272 | 273 | .cm-s-number { color: #4548af; } 274 | .cm-s-string, .cm-s-menu { color: #904949; } 275 | .cm-s-color { color: #b09542; } 276 | .cm-s-comment { color: #c8b898; } 277 | 278 | .cm-s-green { color: #488d00; } 279 | 280 | .cm-s-error { color: #e21313; } 281 | .cm-s-motion { color: #4a6cd4; } 282 | .cm-s-looks { color: #8a55d7; } 283 | .cm-s-sound { color: #bb42c3; } 284 | .cm-s-pen { color: #0e9a6c; } 285 | .cm-s-events { color: #c88330; } 286 | .cm-s-control, .false { color: #e1a91a; } 287 | .cm-s-sensing { color: #2ca5e2; } 288 | .cm-s-operators { color: #5cb712; } 289 | .cm-s-variable { color: #ee7d16; } 290 | .cm-s-custom { color: #632d99; } 291 | .cm-s-parameter { color: #5947b1; } 292 | .cm-s-list { color: #cc5b22; } 293 | .cm-s-extension { color: #4b4a60; } 294 | .cm-s-grey { color: #888; } 295 | 296 | .bg-motion { background: #4a6cd4; } 297 | .bg-looks { background: #8a55d7; } 298 | .bg-sound { background: #bb42c3; } 299 | .bg-pen { background: #0e9a6c; } 300 | .bg-events { background: #c88330; } 301 | .bg-control, .false { background: #e1a91a; } 302 | .bg-sensing { background: #2ca5e2; } 303 | .bg-operators { background: #5cb712; } 304 | .bg-variable { background: #ee7d16; } 305 | .bg-custom { background: #632d99; } 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | /* for generator */ 322 | 323 | 324 | /* Row */ 325 | 326 | #header, #wrap, #sprites-list-wrap, #intro { 327 | position: absolute; 328 | overflow: hidden; 329 | left: 0; 330 | right: 0; 331 | padding: 1em; 332 | } 333 | 334 | #header { 335 | top: 0; 336 | } 337 | 338 | 339 | /* Column */ 340 | 341 | #left-pane, #sprite-detail, #intro { 342 | position: absolute; 343 | overflow: hidden; 344 | overflow-y: auto; 345 | top: 0; 346 | right: 0; 347 | bottom: 0; 348 | padding: 2em; 349 | } 350 | 351 | 352 | /* Intro pane */ 353 | 354 | #intro { 355 | z-index: 201; 356 | background: #fff; 357 | padding: 1em 2em; 358 | } 359 | .hidden { 360 | display: none; 361 | } 362 | 363 | 364 | /* Header stuff */ 365 | 366 | #header { 367 | height: 9.5em; 368 | box-sizing: border-box; 369 | -moz-box-sizing: border-box; 370 | z-index: 202; 371 | padding: 1em 2em; 372 | } 373 | 374 | 375 | #project-url { 376 | font-size: 1.25em; 377 | font-weight: 100; 378 | color: rgba(0, 0, 0, 0.75); 379 | width: 24em; 380 | } 381 | #fetch { 382 | margin: 0; 383 | } 384 | #status { 385 | display: inline-block; 386 | margin-left: 0.5em; 387 | } 388 | #bookmarklet { 389 | background: #888; 390 | color: #fff; 391 | border-radius: 1em; 392 | text-decoration: none; 393 | padding: 0.125em 0.25em; 394 | font-size: 0.9em; 395 | } 396 | 397 | 398 | #wrap { 399 | top: 9.5em; 400 | bottom: 0; 401 | } 402 | 403 | 404 | /* Left pane */ 405 | 406 | #left-pane { 407 | width: 14rem; 408 | left: 0; 409 | } 410 | #sprites-list-wrap { 411 | overflow-y: auto; 412 | top: 9.5em; 413 | bottom: 2em; 414 | margin: 0 2em; 415 | padding: 0; 416 | border: 1px solid #888; 417 | } 418 | #sprites-list { 419 | border-right: 0.5em solid #4ca6fb; 420 | min-height: 2em; 421 | margin: 0; 422 | padding: 0; 423 | list-style: none; 424 | cursor: default; 425 | min-height: 100%; 426 | } 427 | #sprites-list > li { 428 | padding: 0.125em 0.5em; 429 | border-bottom: 1px solid #eee; 430 | } 431 | #sprites-list > li.selected { 432 | background: #4ca6fb; 433 | } 434 | 435 | 436 | #chosen-scripts-info { 437 | } 438 | #num-chosen-scripts { 439 | font-size: 2em; 440 | float: left; 441 | margin-right: 0.25em; 442 | min-width: 1.125em; 443 | text-align: right; 444 | } 445 | #export { 446 | clear: both; 447 | } 448 | 449 | 450 | /* Right pane */ 451 | 452 | #sprite-detail { 453 | left: 12rem; 454 | right: 0; 455 | } 456 | #sprite-info { 457 | overflow: hidden; /* clearfix */ 458 | } 459 | 460 | 461 | #sprite-name { 462 | float: left; 463 | font-size: 1.5em; 464 | margin: 0 1.2222222em; 465 | } 466 | #costume-preview { 467 | float: left; 468 | width: 6em; 469 | height: 6em; 470 | border: 1px solid #888; 471 | } 472 | #costume-preview img { 473 | width: 100%; 474 | } 475 | 476 | 477 | 478 | 479 | img .hidden { 480 | position: absolute; 481 | opacity: 0; 482 | } 483 | 484 | -------------------------------------------------------------------------------- /src/package_commands.py: -------------------------------------------------------------------------------- 1 | import regex 2 | 3 | ws = regex.compile(r'( )+') 4 | contents = open('commands.js').read().replace("\n", " ") 5 | encoded, _ = ws.subn(lambda x: x.group(1), contents) 6 | 7 | sc = regex.compile(r'var scratchCommands = (.*)') 8 | js = open('scratchblocks.js', 'r').read() 9 | js = sc.sub("var scratchCommands = {}".format(encoded.strip()), js) 10 | open('scratchblocks.js', 'w').write(js) 11 | 12 | -------------------------------------------------------------------------------- /tests/all-blocks-de.txt: -------------------------------------------------------------------------------- 1 | // Motion 2 | gehe (10)er-Schritt 3 | drehe dich nach rechts um (15) Grad 4 | drehe dich ↺ um (10) Grad 5 | drehe dich nach links um (15) Grad 6 | drehe dich ↻ um (10) Grad 7 | 8 | // no longer supported -- should they be? 9 | drehe dich im Uhrzeigersinn um (15) Grad 10 | drehe dich gegen den Uhrzeigersinn um (15) Grad // 11 | 12 | setze Richtung auf (90 v) 13 | drehe dich zu [ v] 14 | 15 | gehe zu x: (0) y: (0) 16 | gehe zu [mouse-pointer v] 17 | gleite in (1) sek. zu x: (0) y: (0) 18 | 19 | ändere x um (10) 20 | setze x auf (0) 21 | ändere y um (10) 22 | setze y auf (0) 23 | 24 | pralle vom Rand ab 25 | 26 | setze Drehtyp auf [left-right v] 27 | 28 | (x-Position) 29 | (y-Position) 30 | (Richtung) 31 | 32 | 33 | 34 | // Looks 35 | sage [Hello!] für (2) Sek. 36 | sage [Hello!] 37 | denke [Hmm...] für (2) Sek. 38 | denke [Hmm...] 39 | 40 | zeige dich 41 | verstecke dich 42 | 43 | wechsle zu Kostüm [costume1 v] 44 | nächstes Kostüm 45 | wechsle zu Bühnenbild [backdrop1 v] 46 | 47 | ändere [color v]-Effekt um (25) 48 | setze [color v]-Effekt auf (0) 49 | schalte Grafikeffekte aus 50 | 51 | ändere Größe um (10) 52 | setze Größe auf (100)% 53 | 54 | komme nach vorn 55 | gehe (1) Ebenen nach hinten 56 | 57 | (Kostümnummer) 58 | (Bühnenbildname) 59 | (Größe) 60 | 61 | // Stage-specific 62 | // Looks 63 | wechsle zu Bühnenbild [backdrop1 v] und warte 64 | nächstes Bühnenbild 65 | 66 | (Bühnenbildnummer) 67 | 68 | 69 | 70 | // Sound 71 | spiele Klang [pop v] 72 | spiele Klang [pop v] ganz 73 | stoppe alle Klänge 74 | 75 | spiele Schlaginstrument (1 v) für (0.2) Schläge 76 | pausiere (0.2) Schläge 77 | 78 | spiele Ton (60 v) für (0.5) Schläge 79 | setze Instrument auf (1 v) 80 | 81 | ändere Lautstärke um (-10) 82 | setze Lautstärke auf (100)% 83 | (Lautstärke :: sound) 84 | 85 | ändere Tempo um (20) 86 | setze Tempo auf (60) Schläge/Min. 87 | (Tempo) 88 | 89 | 90 | 91 | // Pen 92 | wische Malspuren weg 93 | 94 | hinterlasse Abdruck 95 | 96 | schalte Stift ein 97 | schalte Stift aus 98 | 99 | setze Stiftfarbe auf [#f0f] 100 | ändere Stiftfarbe um (10) 101 | setze Stiftfarbe auf (0) 102 | 103 | ändere Farbstärke um (10) 104 | setze Farbstärke auf (50) 105 | 106 | ändere Stiftdicke um (1) 107 | setze Stiftdicke auf (1) 108 | 109 | 110 | 111 | // Variables 112 | setze [var v] auf [0] 113 | ändere [var v] um (1) 114 | zeige Variable [var v] 115 | verstecke Variable [var v] 116 | 117 | 118 | 119 | // List 120 | füge [thing] zu [list v] hinzu 121 | 122 | lösche (1 v) aus [list v] 123 | füge [thing] als (1 v) in [list v] ein 124 | ersetze Element (1 v) von [list v] durch [thing] 125 | 126 | (Element (1 v) von [list v]) 127 | (Länge von [list v]) 128 | <[list v] enthält [thing]> 129 | 130 | zeige Liste [list v] 131 | verstecke Liste [list v] 132 | 133 | 134 | 135 | // Events 136 | Wenn die grüne Flagge angeklickt 137 | Wenn ⚑ angeklickt 138 | Wenn Taste [space v] gedrückt 139 | Wenn ich angeklickt werde 140 | Wenn das Bühnenbild zu [backdrop1 v] wechselt 141 | 142 | Wenn [loudness v] > (10) 143 | 144 | Wenn ich [message1 v] empfange 145 | sende [message1 v] an alle 146 | sende [message1 v] an alle und warte 147 | 148 | // should these aliases be supported, too? 149 | Wenn gf angeklickt 150 | Wenn grüne Flagge angeklickt 151 | Wenn Flagge angeklickt 152 | 153 | 154 | // Control 155 | warte (1) Sek. 156 | 157 | wiederhole (10) mal 158 | ende 159 | 160 | wiederhole fortlaufend 161 | ende 162 | 163 | falls <> dann 164 | ende 165 | 166 | falls <> dann 167 | sonst 168 | ende 169 | 170 | warte bis <> 171 | 172 | wiederhole bis <> 173 | ende 174 | 175 | stoppe [alles v] 176 | 177 | stoppe [dieses Skript v] 178 | 179 | stoppe [andere Skripte der Figur v] 180 | 181 | Wenn ich als Klon entstehe 182 | erzeuge Klon von [mir selbst v] 183 | lösche diesen Klon 184 | 185 | 186 | 187 | // Sensing 188 | 189 | 190 | 191 | (Entfernung von [ v]) 192 | 193 | Frage [What's your name?] und warte 194 | (Antwort) 195 | 196 | 197 | 198 | (Maus x-Position) 199 | (Maus y-Position) 200 | 201 | (Lautstärke) 202 | 203 | (Video [motion v] auf [this sprite v]) 204 | schalte Video [on v] 205 | setze Video-Transparenz auf (50)% 206 | 207 | (Stoppuhr) 208 | setze Stoppuhr zurück 209 | 210 | ([x-Position v] von [Sprite1 v]) 211 | 212 | ([minute v] im Moment) 213 | (Tage seit 2000) 214 | (Benutzername) 215 | (user id) 216 | 217 | 218 | 219 | // Operators 220 | (() + ()) 221 | (() - ()) 222 | (() * ()) 223 | (() / ()) 224 | 225 | (Zufallszahl von (1) bis (10)) 226 | 227 | <[] < []> 228 | <[] = []> 229 | <[] > []> 230 | 231 | <<> und <>> 232 | <<> oder <>> 233 | > 234 | 235 | (verbinde [hello ] [world]) 236 | (Zeichen (1) von [world]) 237 | (Länge von [world]) 238 | 239 | (() mod ()) 240 | (() gerundet) 241 | 242 | ([Wurzel v] von (9)) 243 | 244 | 245 | 246 | // Purple 247 | Wenn [button pressed v] 248 | 249 | (Wert von Sensor [slider v]) 250 | 251 | schalte Motor für (1) Sekunden an 252 | schalte Motor an 253 | schalte Motor aus 254 | setze Motorkraft auf (100) 255 | setze Motorrichtung auf [this way v] 256 | 257 | Wenn Abstand < (20) 258 | Wenn Neigung = (1) 259 | (Abstand) 260 | (Neigung) 261 | 262 | 263 | 264 | // Obsolete Scratch 1.4 blocks 265 | 266 | // Looks 267 | ziehe Kostüm [costume1 v] an 268 | 269 | wechsle zum Hintergrund [background1 v] 270 | nächster Hintergrund 271 | (Hintergrund Nr.) 272 | 273 | 274 | 275 | // Control 276 | falls <> 277 | ende 278 | 279 | wiederhole fortlaufend falls <> 280 | ende 281 | 282 | stoppe dieses Skript 283 | stoppe alles 284 | 285 | 286 | 287 | // Events 288 | Wenn angeklickt 289 | 290 | 291 | 292 | // Sensing 293 | 294 | 295 | 296 | 297 | // Purple 298 | schalte Motor an 299 | schalte Motor aus 300 | schalte Motor für (1) Sekunden an 301 | setze Motorkraft auf (100) 302 | setze Motorrichtung auf [this way v] 303 | -------------------------------------------------------------------------------- /tests/all-blocks.txt: -------------------------------------------------------------------------------- 1 | // Motion 2 | 3 | move (10) steps 4 | turn cw (15) degrees 5 | turn right (15) degrees 6 | turn ↻ (15) degrees 7 | turn ccw (15) degrees 8 | turn left (15) degrees 9 | turn ↺ (15) degrees 10 | 11 | point in direction (90 v) 12 | point towards [ v] 13 | 14 | go to x: (0) y: (0) 15 | go to [mouse-pointer v] 16 | glide (1) secs to x: (0) y: (0) 17 | 18 | change x by (10) 19 | set x to (0) 20 | change y by (10) 21 | set y to (0) 22 | 23 | if on edge, bounce 24 | 25 | set rotation style [left-right v] 26 | 27 | (x position) 28 | (y position) 29 | (direction) 30 | 31 | 32 | 33 | // Looks 34 | 35 | say [Hello!] for (2) secs 36 | say [Hello!] 37 | think [Hmm...] for (2) secs 38 | think [Hmm...] 39 | 40 | show 41 | hide 42 | 43 | switch costume to [costume1 v] 44 | next costume 45 | switch backdrop to [backdrop1 v] 46 | 47 | change [color v] effect by (25) 48 | set [color v] effect to (0) 49 | clear graphic effects 50 | 51 | change size by (10) 52 | set size to (100)% 53 | 54 | go to front 55 | go back (1) layers 56 | 57 | (costume #) 58 | (backdrop name) 59 | (size) 60 | 61 | // (Stage-specific) 62 | 63 | switch backdrop to [backdrop1 v] and wait 64 | next backdrop 65 | 66 | (backdrop #) 67 | 68 | 69 | 70 | // Sound 71 | 72 | play sound [pop v] 73 | play sound [pop v] until done 74 | stop all sounds 75 | 76 | play drum (1 v) for (0.2) beats 77 | rest for (0.2) beats 78 | 79 | play note (60 v) for (0.5) beats 80 | set instrument to (1 v) 81 | 82 | change volume by (-10) 83 | set volume to (100)% 84 | (volume) 85 | 86 | change tempo by (20) 87 | set tempo to (60) bpm 88 | (tempo) 89 | 90 | 91 | 92 | // Pen 93 | 94 | clear 95 | 96 | stamp 97 | 98 | pen down 99 | pen up 100 | 101 | set pen color to [#f0f] 102 | change pen color by (10) 103 | set pen color to (0) 104 | 105 | change pen shade by (10) 106 | set pen shade to (50) 107 | 108 | change pen size by (1) 109 | set pen size to (1) 110 | 111 | 112 | 113 | // Variables 114 | 115 | set [var v] to [0] 116 | change [var v] by (1) 117 | show variable [var v] 118 | hide variable [var v] 119 | 120 | 121 | 122 | // List 123 | 124 | add [thing] to [list v] 125 | 126 | delete (1 v) of [list v] 127 | insert [thing] at (1 v) of [list v] 128 | replace item (1 v) of [list v] with [thing] 129 | 130 | (item (1 v) of [list v]) 131 | (length of [list v]) 132 | <[list v] contains [thing]> 133 | 134 | show list [list v] 135 | hide list [list v] 136 | 137 | 138 | 139 | // Events 140 | 141 | when gf clicked 142 | when green flag clicked 143 | when flag clicked 144 | when ⚑ clicked 145 | when [space v] key pressed 146 | when this sprite clicked 147 | when backdrop switches to [backdrop1 v] 148 | 149 | when [loudness v] > (10) 150 | 151 | when I receive [message1 v] 152 | broadcast [message1 v] 153 | broadcast [message1 v] and wait 154 | 155 | 156 | 157 | // Control 158 | 159 | wait (1) secs 160 | 161 | repeat (10) 162 | end 163 | 164 | forever 165 | end 166 | 167 | if <> then 168 | end 169 | 170 | if <> then 171 | else 172 | end 173 | 174 | wait until <> 175 | 176 | repeat until <> 177 | end 178 | 179 | // caps! 180 | 181 | stop [all v] 182 | 183 | stop [this script v] 184 | 185 | // stack 186 | 187 | stop [other scripts in sprite v] 188 | 189 | stop [other scripts in stage v] 190 | 191 | when I start as a clone 192 | create clone of [myself v] 193 | delete this clone 194 | 195 | 196 | 197 | // Sensing 198 | 199 | 200 | 201 | 202 | (distance to [ v]) 203 | 204 | ask [What's your name?] and wait 205 | (answer) 206 | 207 | 208 | 209 | (mouse x) 210 | (mouse y) 211 | 212 | (loudness) 213 | 214 | (video [motion v] on [this sprite v]) 215 | turn video [on v] 216 | set video transparency to (50)% 217 | 218 | (timer) 219 | reset timer 220 | 221 | ([x position v] of [Sprite1 v]) 222 | 223 | (current [minute v]) 224 | (days since 2000) 225 | (username) 226 | (user id) 227 | 228 | 229 | 230 | // Operators 231 | 232 | (() + ()) 233 | (() - ()) 234 | (() * ()) 235 | (() / ()) 236 | 237 | (pick random (1) to (10)) 238 | 239 | <[] < []> 240 | <[] = []> 241 | <[] > []> 242 | 243 | <<> and <>> 244 | <<> or <>> 245 | > 246 | 247 | (join [hello ] [world]) 248 | (letter (1) of [world]) 249 | (length of [world]) 250 | 251 | (() mod ()) 252 | (round ()) 253 | 254 | ([sqrt v] of (9)) 255 | 256 | 257 | // PicoBoard 258 | 259 | when [button pressed v] 260 | 261 | when [slider v] [> v] (50) 262 | 263 | 328 | end 329 | 330 | forever if <> 331 | end 332 | 333 | stop script 334 | stop all 335 | 336 | 337 | 338 | // Events 339 | 340 | when Sprite1 clicked 341 | 342 | 343 | 344 | // Sensing 345 | 346 | 347 | 348 | 349 | 350 | // Grey 351 | 352 | . . . 353 | ... 354 | … 355 | 356 | -------------------------------------------------------------------------------- /tests/images.txt: -------------------------------------------------------------------------------- 1 | turn cw (15) degrees 2 | turn right (15) degrees 3 | turn ↻ (15) degrees 4 | turn @ (15) degrees 5 | 6 | turn ccw (15) degrees 7 | turn left (15) degrees 8 | turn ↺ (15) degrees 9 | 10 | when gf clicked 11 | when green flag clicked 12 | when flag clicked 13 | when @ clicked 14 | when ⚑ clicked 15 | -------------------------------------------------------------------------------- /tests/languages.txt: -------------------------------------------------------------------------------- 1 | when gf clicked 2 | move (10) steps 3 | 4 | // German 5 | 6 | wenn die grune flagge angeklickt 7 | gehe (10) er-Schritt 8 | drehe dich nach rechts um (15) Grad 9 | 10 | // Spanish 11 | 12 | al presionar bandera verde 13 | por siempre 14 | girar a la izquierda (7) grados 15 | girar a la derecha (11) grados 16 | fin 17 | 18 | // Chinese 19 | 20 | 点击绿旗时 21 | 转动CCW (15)度 22 | 转动CW (15)度 23 | 如果 <声音响亮?> 那么 24 | 结束 25 | 26 | // Polish 27 | 28 | kiedy kliknięto zieloną flagę 29 | obróć w lewo o (10) stopni 30 | obróć w prawo o (10) stopni 31 | forever 32 | koniec 33 | -------------------------------------------------------------------------------- /tests/line-test.txt: -------------------------------------------------------------------------------- 1 | // reporters 2 | (variable) 3 | 4 | 5 | // inserts -> stack block 6 | [cheesecake] 7 | (3.12) 8 | (menu v) 9 | [dropdown v] 10 | 11 | // stacks 12 | stamp 13 | say [hi] 14 | [thing] (123) (variable) 15 | [attribute v] of [Stage v] 16 | -------------------------------------------------------------------------------- /tests/lt-gt.txt: -------------------------------------------------------------------------------- 1 | <[10]<(bar)> 2 | <[10]<[11]> 3 | <(foo)<(bar)> 4 | <(foo)<[11]> 5 | <[10]>(bar)> 6 | <[10]>[11]> 7 | <(foo)>(bar)> 8 | <(foo)>[11]> 9 | <<><<>> 10 | <<>><>> 11 | 12 | -------------------------------------------------------------------------------- /tests/of-block.txt: -------------------------------------------------------------------------------- 1 | // green 2 | (length of [world]) 3 | (length of (var)) 4 | (length of (4)) 5 | 6 | ([sqrt v] of (9)) 7 | ([sqrt v] of [4]) 8 | ([sqrt v] of (var)) 9 | 10 | ([e^ v] of (9)) 11 | ([e ^ v] of (9)) 12 | 13 | // blue 14 | ([x position v] of [Sprite1 v]) 15 | ([x position v] of (var)) 16 | 17 | // red 18 | (length of [list v]) 19 | 20 | -------------------------------------------------------------------------------- /tests/snap-hacks.txt: -------------------------------------------------------------------------------- 1 | run ((create clone :: control) ▶ :: grey) :: control 2 | 3 | (() :: grey ring) 4 | (<> :: grey ring) 5 | ({} :: grey ring) 6 | ({stamp} :: grey ring) 7 | 8 | say (http:// [snap.berkeley.edu] :: sensing) 9 | 10 | ((6) × (7) :: operators) 11 | 12 | (join [hello ] [world] ◀ ▶ :: operators) 13 | 14 | script variables ((foo) :: grey) ((bar) :: grey) ▶ :: grey 15 | 16 | (all but first of (list) :: list) 17 | 18 | warp :: grey cstart 19 | move (10) steps 20 | end 21 | report [Done!] :: control cap 22 | -------------------------------------------------------------------------------- /tests/stop-block.txt: -------------------------------------------------------------------------------- 1 | // cap 2 | 3 | stop [all v] 4 | stop [this sprite v] 5 | 6 | stop [otherscriptsinsprite v] 7 | 8 | // stack 9 | 10 | stop [other scripts in sprite v] 11 | 12 | stop [other scripts in sprite v] 13 | -------------------------------------------------------------------------------- /tests/stress-test.txt: -------------------------------------------------------------------------------- 1 | // All the scripts from my "Roads" project. ~blob8108 2 | 3 | when green flag clicked 4 | set [Level_index v] to [1] 5 | broadcast [Hide Cars v] 6 | clear graphic effects 7 | 8 | 9 | when green flag clicked 10 | clear 11 | wait (0) secs 12 | wait (0) secs 13 | if > 14 | broadcast [blob8108 v] and wait 15 | end 16 | broadcast [Previews v] 17 | 18 | 19 | set [Levels v] to [0] 20 | delete (all v) of [Tiles v] 21 | delete (all v) of [Tile Surroundings.1 v] 22 | delete (all v) of [Tile Surroundings.2 v] 23 | delete (all v) of [Tile Switches v] 24 | delete (all v) of [Level Names v] 25 | broadcast [Previews v] 26 | 27 | 28 | when [c v] key pressed 29 | reset timer 30 | wait until <<(timer) > [3]> or >> 31 | if <<(timer) > [3]> and > 32 | broadcast [New Level v] and wait 33 | end 34 | 35 | 36 | when [0 v] key pressed 37 | set [Selected v] to [0] 38 | 39 | 40 | when [1 v] key pressed 41 | set [Selected v] to [1] 42 | 43 | 44 | when [2 v] key pressed 45 | set [Selected v] to [2] 46 | 47 | 48 | when [3 v] key pressed 49 | set [Selected v] to [3] 50 | 51 | 52 | when [4 v] key pressed 53 | set [Selected v] to [4] 54 | 55 | 56 | when [r v] key pressed 57 | broadcast [Refresh All v] 58 | 59 | 60 | when I receive [Reset Vehicles v] 61 | wait (0.2) secs 62 | broadcast [Drive v] 63 | 64 | 65 | when green flag clicked 66 | set [processing v] to [0] 67 | hide 68 | set [Selected v] to [1] 69 | 70 | 71 | when I receive [Stop v] 72 | set [processing v] to [1] 73 | hide 74 | 75 | 76 | when I receive [Start v] 77 | set [processing v] to [0] 78 | wait until > 79 | clear graphic effects 80 | repeat until <<(processing)=[1]> or <(Previewing)=[1]>> 81 | if <<<(mouse x) > [-240]> and <(mouse x) < [240]>> and <<(mouse y) > [-180]> and <(mouse y) < [156]>>> 82 | go to x:(((mouse x) - ((mouse x) mod (24))) + (12)) y:(((mouse y) - (((mouse y) + (12)) mod (24))) + (12)) 83 | set [ghost v] effect to (50) 84 | show 85 | if < or > 86 | set [x v] to (round ((((x position) - (12)) / (24)) + (10))) 87 | set [y v] to (((y position) / (24)) + (7)) 88 | hide 89 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 90 | set [Current Type v] to (item (tile_index) of [Tiles v]) 91 | if 92 | set [Build Type v] to [0] 93 | else 94 | if <<<(Current Type)=[1]> and <(Selected)=[2]>> or <<(Current Type)=[2]> and <(Selected)=[1]>>> 95 | set [Build Type v] to [3] 96 | else 97 | set [Build Type v] to (Selected) 98 | if <(Selected) > [2]> 99 | change [Build Type v] by (1) 100 | end 101 | end 102 | end 103 | switch to costume [blank v] 104 | set [ghost v] effect to (0) 105 | stamp 106 | if > 107 | replace item (tile_index) of [Tiles v] with (Build Type) 108 | else 109 | replace item (tile_index) of [Tile Switches v] with (((item (tile_index) of [Tile Switches v]) mod (2)) + (1)) 110 | broadcast [Update Tile Surroundings v] and wait 111 | end 112 | if <(Build Type) > [0]> 113 | if <(Build Type) > [3]> 114 | if <(Build Type)=[4]> 115 | switch to costume ((36) + (pick random (0) to (1))) 116 | stamp 117 | else 118 | if <(Build Type)=[5]> 119 | switch to costume ((38) + (pick random (1) to (16))) 120 | set [Surroundings v] to (item ((tile_index) - (20)) of [Tile Surroundings.1 v]) 121 | stamp 122 | else 123 | end 124 | end 125 | end 126 | if <<(Build Type)=[1]> or <(Build Type)=[3]>> 127 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.1 v]) 128 | switch to costume ((((1) - (1)) * (17)) + ((Surroundings) + (1))) 129 | stamp 130 | end 131 | if <<(Build Type)=[2]> or <(Build Type)=[3]>> 132 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.2 v]) 133 | if <<<(Surroundings)=[8]> or <(Surroundings)=[12]>> or <<(Surroundings)=[14]> or <(Surroundings)=[15]>>> 134 | set [brightness v] effect to (50) 135 | switch to costume ((((2) - (1)) * (17)) + ((Surroundings) + (1))) 136 | stamp 137 | set [brightness v] effect to (0) 138 | set [switch v] to (item (tile_index) of [Tile Switches v]) 139 | if <<<(Surroundings)=[8]> and <(switch)=[1]>> or <<(Surroundings)=[12]> and <(switch)=[2]>>> 140 | switch to costume [ul1 v] 141 | end 142 | if <<<(Surroundings)=[8]> and <(switch)=[2]>> or <<(Surroundings)=[15]> and <(switch)=[1]>>> 143 | switch to costume [ld1 v] 144 | end 145 | if <<<(Surroundings)=[12]> and <(switch)=[1]>> or <<(Surroundings)=[14]> and <(switch)=[2]>>> 146 | switch to costume [ur1 v] 147 | end 148 | if <<<(Surroundings)=[14]> and <(switch)=[1]>> or <<(Surroundings)=[15]> and <(switch)=[2]>>> 149 | switch to costume [dr1 v] 150 | end 151 | stamp 152 | else 153 | switch to costume ((((2) - (1)) * (17)) + ((Surroundings) + (1))) 154 | stamp 155 | end 156 | end 157 | end 158 | if > 159 | if <<(Current Type) > [0]> and <(Current Type) < [4]>> 160 | set [Build Modifier v] to [-1] 161 | if <<(Current Type)=[1]> or <(Current Type)=[3]>> 162 | broadcast [Rebuild Surroundings 1.Road v] and wait 163 | end 164 | if <<(Current Type)=[2]> or <(Current Type)=[3]>> 165 | broadcast [Rebuild Surroundings 2.Rails v] and wait 166 | end 167 | end 168 | if <<(Build Type) > [0]> and <(Build Type) < [4]>> 169 | set [Build Modifier v] to [1] 170 | if <<(Build Type)=[1]> or <(Build Type)=[3]>> 171 | broadcast [Rebuild Surroundings 1.Road v] and wait 172 | end 173 | if <<(Build Type)=[2]> or <(Build Type)=[3]>> 174 | broadcast [Rebuild Surroundings 2.Rails v] and wait 175 | end 176 | end 177 | if <<(Current Type)=[5]> or <<<(Current Type) > [0]> and <(Current Type) < [4]>> or <<(Build Type) > [0]> and <(Build Type) < [4]>>>> 178 | broadcast [Restamp neighbours v] and wait 179 | end 180 | end 181 | if <(Build Type)=[5]> 182 | set [Surroundings v] to (item ((tile_index) - (20)) of [Tile Surroundings.1 v]) 183 | if <<<(item ((tile_index) - (20)) of [Tiles v])=[1]> or <(item ((tile_index) - (20)) of [Tiles v])=[3]>> and <<<(Surroundings)=[3]> or <(Surroundings)=[9]>> or <<(Surroundings)=[11]> or <(Surroundings)=[15]>>>> 184 | switch to costume [drive v] 185 | stamp 186 | end 187 | end 188 | if <(Build Type)=[3]> 189 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 190 | set [Surroundings.1 v] to (item (tile_index) of [Tile Surroundings.1 v]) 191 | set [Surroundings.2 v] to (item (tile_index) of [Tile Surroundings.2 v]) 192 | if <<<(Surroundings.1)=[6]> and <(Surroundings.2)=[11]>> or <<(Surroundings.1)=[11]> and <(Surroundings.2)=[6]>>> 193 | broadcast [Stamp Crossing v] and wait 194 | end 195 | end 196 | set [nx v] to (x) 197 | set [ny v] to (y) 198 | repeat until < and <(ny)=(y)>>> or >> 199 | go to x:(((mouse x) - ((mouse x) mod (24))) + (12)) y:(((mouse y) - (((mouse y) + (12)) mod (24))) + (12)) 200 | set [nx v] to ((((x position) - (12)) / (24)) + (10)) 201 | set [ny v] to (((y position) / (24)) + (7)) 202 | end 203 | else 204 | if <(Selected)=[4]> 205 | switch to costume [house1 v] 206 | else 207 | if <(Selected)=[3]> 208 | switch to costume [tree v] 209 | else 210 | switch to costume (((Selected) * (17)) + (1)) 211 | end 212 | end 213 | end 214 | else 215 | hide 216 | end 217 | end 218 | 219 | 220 | when I receive [Restamp neighbours v] 221 | clear graphic effects 222 | change [x v] by (1) 223 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 224 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 225 | set [Type v] to (item (tile_index) of [Tiles v]) 226 | if <(Type) > [0]> 227 | go to x:((((x) - (10)) * (24)) + (12)) y:(((y) - (7)) * (24)) 228 | switch to costume [blank v] 229 | stamp 230 | broadcast [Stamp v] and wait 231 | if <<(Type)=[1]> and <(item ((tile_index) + (20)) of [Tiles v])=[5]>> 232 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.1 v]) 233 | if <<<(Surroundings)=[3]> or <(Surroundings)=[9]>> or <<(Surroundings)=[11]> or <(Surroundings)=[15]>>> 234 | change y by (24) 235 | switch to costume [drive v] 236 | stamp 237 | end 238 | end 239 | end 240 | end 241 | change [x v] by (-2) 242 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 243 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 244 | set [Type v] to (item (tile_index) of [Tiles v]) 245 | if <(Type) > [0]> 246 | go to x:((((x) - (10)) * (24)) + (12)) y:(((y) - (7)) * (24)) 247 | switch to costume [blank v] 248 | stamp 249 | broadcast [Stamp v] and wait 250 | if <<(Type)=[1]> and <(item ((tile_index) + (20)) of [Tiles v])=[5]>> 251 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.1 v]) 252 | if <<<(Surroundings)=[3]> or <(Surroundings)=[9]>> or <<(Surroundings)=[11]> or <(Surroundings)=[15]>>> 253 | change y by (24) 254 | switch to costume [drive v] 255 | stamp 256 | end 257 | end 258 | end 259 | end 260 | change [x v] by (1) 261 | change [y v] by (1) 262 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 263 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 264 | set [Type v] to (item (tile_index) of [Tiles v]) 265 | if <(Type) > [0]> 266 | go to x:((((x) - (10)) * (24)) + (12)) y:(((y) - (7)) * (24)) 267 | switch to costume [blank v] 268 | stamp 269 | broadcast [Stamp v] and wait 270 | if <<(Type)=[1]> and <(item ((tile_index) + (20)) of [Tiles v])=[5]>> 271 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.1 v]) 272 | if <<<(Surroundings)=[3]> or <(Surroundings)=[9]>> or <<(Surroundings)=[11]> or <(Surroundings)=[15]>>> 273 | change y by (24) 274 | switch to costume [drive v] 275 | stamp 276 | end 277 | end 278 | end 279 | end 280 | change [y v] by (-2) 281 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 282 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 283 | set [Type v] to (item (tile_index) of [Tiles v]) 284 | if <(Type) > [0]> 285 | go to x:((((x) - (10)) * (24)) + (12)) y:(((y) - (7)) * (24)) 286 | switch to costume [blank v] 287 | stamp 288 | broadcast [Stamp v] and wait 289 | if <<(Type)=[1]> and <(item ((tile_index) + (20)) of [Tiles v])=[5]>> 290 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.1 v]) 291 | if <<<(Surroundings)=[3]> or <(Surroundings)=[9]>> or <<(Surroundings)=[11]> or <(Surroundings)=[15]>>> 292 | change y by (24) 293 | switch to costume [drive v] 294 | stamp 295 | end 296 | end 297 | end 298 | end 299 | 300 | 301 | when I receive [Rebuild Surroundings 1.Road v] 302 | change [x v] by (1) 303 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 304 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 305 | set [Type v] to (item (tile_index) of [Tiles v]) 306 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.1 v]) 307 | change [Surroundings v] by ((2) * (Build Modifier)) 308 | replace item (tile_index) of [Tile Surroundings.1 v] with (Surroundings) 309 | end 310 | change [x v] by (-2) 311 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 312 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 313 | set [Type v] to (item (tile_index) of [Tiles v]) 314 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.1 v]) 315 | change [Surroundings v] by ((8) * (Build Modifier)) 316 | replace item (tile_index) of [Tile Surroundings.1 v] with (Surroundings) 317 | end 318 | change [x v] by (1) 319 | change [y v] by (1) 320 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 321 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 322 | set [Type v] to (item (tile_index) of [Tiles v]) 323 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.1 v]) 324 | change [Surroundings v] by ((4) * (Build Modifier)) 325 | replace item (tile_index) of [Tile Surroundings.1 v] with (Surroundings) 326 | end 327 | change [y v] by (-2) 328 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 329 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 330 | set [Type v] to (item (tile_index) of [Tiles v]) 331 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.1 v]) 332 | change [Surroundings v] by ((1) * (Build Modifier)) 333 | replace item (tile_index) of [Tile Surroundings.1 v] with (Surroundings) 334 | end 335 | change [y v] by (1) 336 | 337 | 338 | when I receive [Rebuild Surroundings 2.Rails v] 339 | change [x v] by (1) 340 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 341 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 342 | set [Type v] to (item (tile_index) of [Tiles v]) 343 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.2 v]) 344 | change [Surroundings v] by ((2) * (Build Modifier)) 345 | replace item (tile_index) of [Tile Surroundings.2 v] with (Surroundings) 346 | end 347 | change [x v] by (-2) 348 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 349 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 350 | set [Type v] to (item (tile_index) of [Tiles v]) 351 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.2 v]) 352 | change [Surroundings v] by ((8) * (Build Modifier)) 353 | replace item (tile_index) of [Tile Surroundings.2 v] with (Surroundings) 354 | end 355 | change [x v] by (1) 356 | change [y v] by (1) 357 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 358 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 359 | set [Type v] to (item (tile_index) of [Tiles v]) 360 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.2 v]) 361 | change [Surroundings v] by ((4) * (Build Modifier)) 362 | replace item (tile_index) of [Tile Surroundings.2 v] with (Surroundings) 363 | end 364 | change [y v] by (-2) 365 | if <<<(x) > [-1]> and <(y) > [-1]>> and <<(x) < [20]> and <(y) < [14]>>> 366 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 367 | set [Type v] to (item (tile_index) of [Tiles v]) 368 | set [Surroundings v] to (item (tile_index) of [Tile Surroundings.2 v]) 369 | change [Surroundings v] by ((1) * (Build Modifier)) 370 | replace item (tile_index) of [Tile Surroundings.2 v] with (Surroundings) 371 | end 372 | change [y v] by (1) 373 | 374 | 375 | when I receive [Update Tile Surroundings v] 376 | set [Surroundings.1 v] to [1] 377 | set [Surroundings.2 v] to [1] 378 | set [tx v] to ((x) + (0)) 379 | set [ty v] to ((y) + (1)) 380 | if <<<(tx) > [-1]> and <(ty) > [-1]>> and <<(tx) < [20]> and <(ty) < [14]>>> 381 | set [tile v] to (item ((round ((tx) + ((ty) * (20)))) + (Level_index)) of [Tiles v]) 382 | if <<(tile)=[1]> or <(tile)=[3]>> 383 | change [Surroundings.1 v] by (1) 384 | end 385 | if <<(tile)=[2]> or <(tile)=[3]>> 386 | change [Surroundings.2 v] by (1) 387 | end 388 | end 389 | set [tx v] to ((x) + (-1)) 390 | set [ty v] to ((y) + (0)) 391 | if <<<(tx) > [-1]> and <(ty) > [-1]>> and <<(tx) < [20]> and <(ty) < [14]>>> 392 | set [tile v] to (item ((round ((tx) + ((ty) * (20)))) + (Level_index)) of [Tiles v]) 393 | if <<(tile)=[1]> or <(tile)=[3]>> 394 | change [Surroundings.1 v] by (2) 395 | end 396 | if <<(tile)=[2]> or <(tile)=[3]>> 397 | change [Surroundings.2 v] by (2) 398 | end 399 | end 400 | set [tx v] to ((x) + (0)) 401 | set [ty v] to ((y) + (-1)) 402 | if <<<(tx) > [-1]> and <(ty) > [-1]>> and <<(tx) < [20]> and <(ty) < [14]>>> 403 | set [tile v] to (item ((round ((tx) + ((ty) * (20)))) + (Level_index)) of [Tiles v]) 404 | if <<(tile)=[1]> or <(tile)=[3]>> 405 | change [Surroundings.1 v] by (4) 406 | end 407 | if <<(tile)=[2]> or <(tile)=[3]>> 408 | change [Surroundings.2 v] by (4) 409 | end 410 | end 411 | set [tx v] to ((x) + (1)) 412 | set [ty v] to ((y) + (0)) 413 | if <<<(tx) > [-1]> and <(ty) > [-1]>> and <<(tx) < [20]> and <(ty) < [14]>>> 414 | set [tile v] to (item ((round ((tx) + ((ty) * (20)))) + (Level_index)) of [Tiles v]) 415 | if <<(tile)=[1]> or <(tile)=[3]>> 416 | change [Surroundings.1 v] by (8) 417 | end 418 | if <<(tile)=[2]> or <(tile)=[3]>> 419 | change [Surroundings.2 v] by (8) 420 | end 421 | end 422 | replace item (tile_index) of [Tile Surroundings.1 v] with (Surroundings.1) 423 | replace item (tile_index) of [Tile Surroundings.2 v] with (Surroundings.2) 424 | 425 | 426 | when I receive [_update surroundings v] 427 | set [Surroundings v] to [1] 428 | set [tx v] to ((x) + (0)) 429 | set [ty v] to ((y) + (1)) 430 | if <<<(tx) > [-1]> and <(ty) > [-1]>> and <<(tx) < [20]> and <(ty) < [14]>>> 431 | set [tile v] to (item ((round ((tx) + ((ty) * (20)))) + (Level_index)) of [Tiles v]) 432 | if <<(tile)=(Type)> or <(tile)=[3]>> 433 | change [Surroundings v] by (1) 434 | end 435 | end 436 | set [tx v] to ((x) + (-1)) 437 | set [ty v] to ((y) + (0)) 438 | if <<<(tx) > [-1]> and <(ty) > [-1]>> and <<(tx) < [20]> and <(ty) < [14]>>> 439 | set [tile v] to (item ((round ((tx) + ((ty) * (20)))) + (Level_index)) of [Tiles v]) 440 | if <<(tile)=(Type)> or <(tile)=[3]>> 441 | change [Surroundings v] by (2) 442 | end 443 | end 444 | set [tx v] to ((x) + (0)) 445 | set [ty v] to ((y) + (-1)) 446 | if <<<(tx) > [-1]> and <(ty) > [-1]>> and <<(tx) < [20]> and <(ty) < [14]>>> 447 | set [tile v] to (item ((round ((tx) + ((ty) * (20)))) + (Level_index)) of [Tiles v]) 448 | if <<(tile)=(Type)> or <(tile)=[3]>> 449 | change [Surroundings v] by (4) 450 | end 451 | end 452 | set [tx v] to ((x) + (1)) 453 | set [ty v] to ((y) + (0)) 454 | if <<<(tx) > [-1]> and <(ty) > [-1]>> and <<(tx) < [20]> and <(ty) < [14]>>> 455 | set [tile v] to (item ((round ((tx) + ((ty) * (20)))) + (Level_index)) of [Tiles v]) 456 | if <<(tile)=(Type)> or <(tile)=[3]>> 457 | change [Surroundings v] by (8) 458 | end 459 | end 460 | if <(Type)=[1]> 461 | replace item (tile_index) of [Tile Surroundings.1 v] with (Surroundings) 462 | end 463 | if <(Type)=[2]> 464 | replace item (tile_index) of [Tile Surroundings.2 v] with (Surroundings) 465 | end 466 | 467 | 468 | when I receive [Stamp v] 469 | clear graphic effects 470 | if <(Type) > [3]> 471 | if <(Type)=[4]> 472 | switch to costume ((36) + (pick random (0) to (1))) 473 | stamp 474 | else 475 | if <(Type)=[5]> 476 | switch to costume ((38) + (pick random (1) to (16))) 477 | set [Surroundings v] to (item ((tile_index) - (20)) of [Tile Surroundings.1 v]) 478 | stamp 479 | if <<<(item ((tile_index) - (20)) of [Tiles v])=[1]> or <(item ((tile_index) - (20)) of [Tiles v])=[3]>> and <<<(Surroundings)=[3]> or <(Surroundings)=[9]>> or <<(Surroundings)=[11]> or <(Surroundings)=[15]>>>> 480 | switch to costume [drive v] 481 | stamp 482 | end 483 | else 484 | end 485 | end 486 | else 487 | set [Surroundings.1 v] to (item (tile_index) of [Tile Surroundings.1 v]) 488 | set [Surroundings.2 v] to (item (tile_index) of [Tile Surroundings.2 v]) 489 | if <<(Type)=[3]> and <<<(Surroundings.1)=[6]> and <(Surroundings.2)=[11]>> or <<(Surroundings.1)=[11]> and <(Surroundings.2)=[6]>>>> 490 | broadcast [Stamp Crossing v] and wait 491 | else 492 | if <<(Type)=[1]> or <(Type)=[3]>> 493 | switch to costume ((((1) - (1)) * (17)) + ((Surroundings.1) + (1))) 494 | stamp 495 | end 496 | if <<(Type)=[2]> or <(Type)=[3]>> 497 | if <<<(Surroundings.2)=[8]> or <(Surroundings.2)=[12]>> or <<(Surroundings.2)=[14]> or <(Surroundings.2)=[15]>>> 498 | set [brightness v] effect to (50) 499 | switch to costume ((((2) - (1)) * (17)) + ((Surroundings.2) + (1))) 500 | stamp 501 | set [brightness v] effect to (0) 502 | set [switch v] to (item (tile_index) of [Tile Switches v]) 503 | if <<<(Surroundings.2)=[8]> and <(switch)=[1]>> or <<(Surroundings.2)=[12]> and <(switch)=[2]>>> 504 | switch to costume [ul1 v] 505 | end 506 | if <<<(Surroundings.2)=[8]> and <(switch)=[2]>> or <<(Surroundings.2)=[15]> and <(switch)=[1]>>> 507 | switch to costume [ld1 v] 508 | end 509 | if <<<(Surroundings.2)=[12]> and <(switch)=[1]>> or <<(Surroundings.2)=[14]> and <(switch)=[2]>>> 510 | switch to costume [ur1 v] 511 | end 512 | if <<<(Surroundings.2)=[14]> and <(switch)=[1]>> or <<(Surroundings.2)=[15]> and <(switch)=[2]>>> 513 | switch to costume [dr1 v] 514 | end 515 | stamp 516 | else 517 | switch to costume ((((2) - (1)) * (17)) + ((Surroundings.2) + (1))) 518 | stamp 519 | end 520 | end 521 | end 522 | end 523 | 524 | 525 | when I receive [Generate Code v] 526 | delete (all v) of [Code v] 527 | set [processing v] to [1] 528 | broadcast [Thinking v] 529 | set [_Code v] to [] 530 | set [Level_index v] to ((((Level) - (1)) * (280)) + (1)) 531 | set [tile_index v] to (Level_index) 532 | repeat (94) 533 | set [Byte v] to [0] 534 | repeat (3) 535 | set [Byte v] to ((Byte) / (4)) 536 | set [Type v] to (item (tile_index) of [Tiles v]) 537 | if <(Type) > [3]> 538 | set [Type v] to [0] 539 | end 540 | change [Byte v] by (Type) 541 | change [tile_index v] by (1) 542 | end 543 | set [Byte v] to (round ((Byte) * (16))) 544 | set [_Code v] to (join (_Code) (item ((Byte) + (1)) of [base64 v])) 545 | end 546 | add (_Code) to [Code v] 547 | set [processing v] to [0] 548 | broadcast [Export instructions v] and wait 549 | 550 | 551 | when I receive [Import Code v] 552 | hide 553 | ask [Import level — paste code here:] and wait 554 | if > 555 | set [processing v] to [1] 556 | broadcast [Thinking v] 557 | broadcast [_new v] and wait 558 | change [Levels v] by (1) 559 | add [Imported] to [Level Names v] 560 | set [_Code v] to (answer) 561 | set [i v] to [1] 562 | set [tile_index2 v] to (Level_index) 563 | repeat (length of (_Code)) 564 | set [Char v] to (letter (i) of (_Code)) 565 | if <[base64 v] contains (Char)> 566 | set [Byte v] to [0] 567 | repeat until <(item ((Byte) + (1)) of [base64 search v])=(Char)> 568 | change [Byte v] by (1) 569 | end 570 | if <[uppercase v] contains (Char)> 571 | change [Byte v] by (26) 572 | end 573 | repeat (3) 574 | set [Type v] to ((Byte) mod (4)) 575 | set [tile_index v] to (tile_index2) 576 | replace item (tile_index) of [Tiles v] with (Type) 577 | set [Build Modifier v] to [1] 578 | change [tile_index2 v] by (1) 579 | change [Byte v] by ((0) - (Type)) 580 | set [Byte v] to ((Byte) / (4)) 581 | end 582 | else 583 | set [processing v] to [0] 584 | stop script 585 | end 586 | change [i v] by (1) 587 | end 588 | set [Build Modifier v] to [1] 589 | set [y v] to [0] 590 | repeat (14) 591 | set [x v] to [0] 592 | repeat (20) 593 | set [tile_index v] to (((x) + ((y) * (20))) + (Level_index)) 594 | broadcast [Update Tile Surroundings v] and wait 595 | change [x v] by (1) 596 | end 597 | change [y v] by (1) 598 | end 599 | set [processing v] to [0] 600 | end 601 | 602 | 603 | when green flag clicked 604 | forever 605 | set [reverse x v] to (((tile_index) - (Level_index)) mod (20)) 606 | set [reverse y v] to ((((tile_index) - (Level_index)) - (reverse x)) / (20)) 607 | end 608 | 609 | 610 | when I receive [Load Level v] 611 | set [Level_index v] to ((((Level) - (1)) * (280)) + (1)) 612 | broadcast [Refresh All v] 613 | 614 | 615 | when I receive [New Level v] 616 | set [processing v] to [1] 617 | broadcast [Hide Cars v] 618 | clear 619 | broadcast [_new v] and wait 620 | set [processing v] to [0] 621 | set [Build Modifier v] to [1] 622 | set [x v] to [9] 623 | set [y v] to [6] 624 | replace item (((x) + ((y) * (20))) + (Level_index)) of [Tiles v] with [1] 625 | broadcast [Rebuild Surroundings 1.Road v] and wait 626 | change [x v] by (1) 627 | replace item (((x) + ((y) * (20))) + (Level_index)) of [Tiles v] with [1] 628 | broadcast [Rebuild Surroundings 1.Road v] and wait 629 | change [y v] by (1) 630 | replace item (((10) + ((7) * (20))) + (Level_index)) of [Tiles v] with [2] 631 | broadcast [Rebuild Surroundings 2.Rails v] and wait 632 | change [x v] by (-1) 633 | replace item (((9) + ((7) * (20))) + (Level_index)) of [Tiles v] with [2] 634 | broadcast [Rebuild Surroundings 2.Rails v] and wait 635 | change [Levels v] by (1) 636 | add (join [Level ] (Levels)) to [Level Names v] 637 | wait (0.2) secs 638 | broadcast [Refresh All v] 639 | 640 | 641 | when I receive [_new v] 642 | set [Level_index v] to ((length of [Tiles v]) + (1)) 643 | repeat ((14) * (20)) 644 | add ([Fill With v] of [newmap v]) to [Tiles v] 645 | add [1] to [Tile Switches v] 646 | add [1] to [Tile Surroundings.1 v] 647 | add [1] to [Tile Surroundings.2 v] 648 | end 649 | 650 | 651 | switch to costume [r1 v] 652 | go to x:(-12) y:(0) 653 | stamp 654 | switch to costume [l1 v] 655 | go to x:(12) y:(0) 656 | stamp 657 | switch to costume [r v] 658 | go to x:(-12) y:(-24) 659 | stamp 660 | switch to costume [l v] 661 | go to x:(12) y:(-24) 662 | stamp 663 | broadcast [Start v] 664 | broadcast [Reset Vehicles v] 665 | 666 | 667 | when I receive [Refresh All v] 668 | set [processing v] to [1] 669 | broadcast [Hide Cars v] 670 | hide 671 | clear graphic effects 672 | clear 673 | broadcast [SuperClear v] 674 | wait (0) secs 675 | wait (0) secs 676 | set [y v] to [0] 677 | set y to (-168) 678 | set [tile_index v] to (Level_index) 679 | repeat (14) 680 | set [x v] to [0] 681 | set x to (-228) 682 | set [Type v] to (item (tile_index) of [Tiles v]) 683 | if <(Type) > [0]> 684 | broadcast [Stamp v] and wait 685 | end 686 | change [tile_index v] by (1) 687 | change [x v] by (1) 688 | change x by (24) 689 | set [Type v] to (item (tile_index) of [Tiles v]) 690 | if <(Type) > [0]> 691 | broadcast [Stamp v] and wait 692 | end 693 | change [tile_index v] by (1) 694 | change [x v] by (1) 695 | change x by (24) 696 | set [Type v] to (item (tile_index) of [Tiles v]) 697 | if <(Type) > [0]> 698 | broadcast [Stamp v] and wait 699 | end 700 | change [tile_index v] by (1) 701 | change [x v] by (1) 702 | change x by (24) 703 | set [Type v] to (item (tile_index) of [Tiles v]) 704 | if <(Type) > [0]> 705 | broadcast [Stamp v] and wait 706 | end 707 | change [tile_index v] by (1) 708 | change [x v] by (1) 709 | change x by (24) 710 | set [Type v] to (item (tile_index) of [Tiles v]) 711 | if <(Type) > [0]> 712 | broadcast [Stamp v] and wait 713 | end 714 | change [tile_index v] by (1) 715 | change [x v] by (1) 716 | change x by (24) 717 | set [Type v] to (item (tile_index) of [Tiles v]) 718 | if <(Type) > [0]> 719 | broadcast [Stamp v] and wait 720 | end 721 | change [tile_index v] by (1) 722 | change [x v] by (1) 723 | change x by (24) 724 | set [Type v] to (item (tile_index) of [Tiles v]) 725 | if <(Type) > [0]> 726 | broadcast [Stamp v] and wait 727 | end 728 | change [tile_index v] by (1) 729 | change [x v] by (1) 730 | change x by (24) 731 | set [Type v] to (item (tile_index) of [Tiles v]) 732 | if <(Type) > [0]> 733 | broadcast [Stamp v] and wait 734 | end 735 | change [tile_index v] by (1) 736 | change [x v] by (1) 737 | change x by (24) 738 | set [Type v] to (item (tile_index) of [Tiles v]) 739 | if <(Type) > [0]> 740 | broadcast [Stamp v] and wait 741 | end 742 | change [tile_index v] by (1) 743 | change [x v] by (1) 744 | change x by (24) 745 | set [Type v] to (item (tile_index) of [Tiles v]) 746 | if <(Type) > [0]> 747 | broadcast [Stamp v] and wait 748 | end 749 | change [tile_index v] by (1) 750 | change [x v] by (1) 751 | change x by (24) 752 | set [Type v] to (item (tile_index) of [Tiles v]) 753 | if <(Type) > [0]> 754 | broadcast [Stamp v] and wait 755 | end 756 | change [tile_index v] by (1) 757 | change [x v] by (1) 758 | change x by (24) 759 | set [Type v] to (item (tile_index) of [Tiles v]) 760 | if <(Type) > [0]> 761 | broadcast [Stamp v] and wait 762 | end 763 | change [tile_index v] by (1) 764 | change [x v] by (1) 765 | change x by (24) 766 | set [Type v] to (item (tile_index) of [Tiles v]) 767 | if <(Type) > [0]> 768 | broadcast [Stamp v] and wait 769 | end 770 | change [tile_index v] by (1) 771 | change [x v] by (1) 772 | change x by (24) 773 | set [Type v] to (item (tile_index) of [Tiles v]) 774 | if <(Type) > [0]> 775 | broadcast [Stamp v] and wait 776 | end 777 | change [tile_index v] by (1) 778 | change [x v] by (1) 779 | change x by (24) 780 | set [Type v] to (item (tile_index) of [Tiles v]) 781 | if <(Type) > [0]> 782 | broadcast [Stamp v] and wait 783 | end 784 | change [tile_index v] by (1) 785 | change [x v] by (1) 786 | change x by (24) 787 | set [Type v] to (item (tile_index) of [Tiles v]) 788 | if <(Type) > [0]> 789 | broadcast [Stamp v] and wait 790 | end 791 | change [tile_index v] by (1) 792 | change [x v] by (1) 793 | change x by (24) 794 | set [Type v] to (item (tile_index) of [Tiles v]) 795 | if <(Type) > [0]> 796 | broadcast [Stamp v] and wait 797 | end 798 | change [tile_index v] by (1) 799 | change [x v] by (1) 800 | change x by (24) 801 | set [Type v] to (item (tile_index) of [Tiles v]) 802 | if <(Type) > [0]> 803 | broadcast [Stamp v] and wait 804 | end 805 | change [tile_index v] by (1) 806 | change [x v] by (1) 807 | change x by (24) 808 | set [Type v] to (item (tile_index) of [Tiles v]) 809 | if <(Type) > [0]> 810 | broadcast [Stamp v] and wait 811 | end 812 | change [tile_index v] by (1) 813 | change [x v] by (1) 814 | change x by (24) 815 | set [Type v] to (item (tile_index) of [Tiles v]) 816 | if <(Type) > [0]> 817 | broadcast [Stamp v] and wait 818 | end 819 | change [tile_index v] by (1) 820 | change [x v] by (1) 821 | change x by (24) 822 | change [y v] by (1) 823 | change y by (24) 824 | end 825 | set [processing v] to [0] 826 | broadcast [Start v] 827 | broadcast [Reset Vehicles v] 828 | 829 | 830 | when green flag clicked 831 | hide 832 | set [processing v] to [0] 833 | 834 | 835 | when I receive [Previews v] 836 | hide 837 | 838 | 839 | when I receive [Start v] 840 | hide 841 | 842 | 843 | when I receive [Stamp Crossing v] 844 | wait until <(processing)=[0]> 845 | go to [placer v] 846 | if <([Surroundings.1 v] of [placer v])=[6]> 847 | switch to costume [6,11: v] 848 | stamp 849 | set [gate dir v] to [1] 850 | else 851 | switch to costume [11,6: v] 852 | stamp 853 | set [gate dir v] to [0] 854 | end 855 | set [gate dir v] to (((gate dir) + (item ([tile_index v] of [placer v]) of [Tile Switches v])) mod (2)) 856 | if <(gate dir)=[1]> 857 | switch to costume [lr v] 858 | else 859 | switch to costume [ud v] 860 | end 861 | stamp 862 | 863 | 864 | when I receive [Crossing Request v] 865 | if <(processing)=[0]> 866 | set [processing v] to [1] 867 | broadcast [_crossing request v] 868 | end 869 | 870 | 871 | when I receive [_crossing request v] 872 | set [tx v] to (crossing.tx) 873 | set [ty v] to (crossing.ty) 874 | set [request type v] to (crossing.requestType) 875 | go to x:((((tx) - (10)) * (24)) + (12)) y:(((ty) - (7)) * (24)) 876 | set [t i v] to (((tx) + ((ty) * (20))) + (Level_index)) 877 | if > 878 | set [processing v] to [0] 879 | stop script 880 | end 881 | if <<(item (t i) of [Tile Surroundings.1 v])=[6]> and <(item (t i) of [Tile Surroundings.2 v])=[11]>> 882 | switch to costume [6,11: v] 883 | stamp 884 | set [gate dir v] to [1] 885 | else 886 | if <<(item (t i) of [Tile Surroundings.1 v])=[11]> and <(item (t i) of [Tile Surroundings.2 v])=[6]>> 887 | switch to costume [11,6: v] 888 | stamp 889 | set [gate dir v] to [0] 890 | else 891 | set [processing v] to [0] 892 | stop script 893 | end 894 | end 895 | set [gate dir v] to (((gate dir) + (request type)) mod (2)) 896 | if <(gate dir)=[1]> 897 | switch to costume [ud v] 898 | show 899 | repeat (4) 900 | wait (0.05) secs 901 | switch to costume ((costume #) - (1)) 902 | end 903 | else 904 | switch to costume [lr v] 905 | show 906 | repeat (4) 907 | wait (0.05) secs 908 | next costume 909 | end 910 | end 911 | stamp 912 | hide 913 | replace item (t i) of [Tile Switches v] with (request type) 914 | wait (0.2) secs 915 | set [processing v] to [0] 916 | 917 | 918 | when green flag clicked 919 | hide 920 | 921 | 922 | when I receive [Hide Cars v] 923 | hide 924 | 925 | 926 | when I receive [Start v] 927 | show 928 | forever 929 | go to x:(0) y:(-24) 930 | go back (100) layers 931 | end 932 | 933 | 934 | when I receive [SuperClear v] 935 | hide 936 | 937 | 938 | when green flag clicked 939 | hide 940 | 941 | 942 | when I receive [SuperClear v] 943 | hide 944 | switch to costume [clearer v] 945 | stamp 946 | switch to costume [trainstn v] 947 | 948 | 949 | when I receive [Start v] 950 | switch to costume [trainstn v] 951 | show 952 | forever 953 | go to x:(0) y:(0) 954 | go back (100) layers 955 | end 956 | 957 | 958 | when green flag clicked 959 | go to x:(-235) y:(170) 960 | forever 961 | if <(Previewing)=[1]> 962 | switch to costume [Previewing v] 963 | else 964 | switch to costume [selected v] 965 | end 966 | end 967 | 968 | 969 | when green flag clicked 970 | forever 971 | switch to costume ((Selected) + (1)) 972 | end 973 | 974 | 975 | when green flag clicked 976 | go to x:(-150) y:(169) 977 | forever 978 | if <(Previewing)=[1]> 979 | hide 980 | else 981 | show 982 | if <<<(mouse y) > [156]> and <(mouse y) < [180]>> and <(mouse x) < [50]>> 983 | set [brightness v] effect to (10) 984 | if 985 | set [brightness v] effect to (0) 986 | if <<(mouse x) > [-150]> and <(mouse x) < [-40]>> 987 | set [Selected v] to ((((mouse x) + (150)) - (((mouse x) + (150)) mod (22))) / (22)) 988 | else 989 | set [Selected v] to (((Selected) + (1)) mod (5)) 990 | end 991 | wait until > 992 | end 993 | else 994 | set [brightness v] effect to (-5) 995 | end 996 | end 997 | end 998 | 999 | 1000 | when green flag clicked 1001 | forever 1002 | go to x:(((Selected) * (21)) - (150)) y:(169) 1003 | end 1004 | 1005 | 1006 | when green flag clicked 1007 | forever 1008 | if <(Previewing)=[1]> 1009 | hide 1010 | else 1011 | show 1012 | end 1013 | end 1014 | 1015 | 1016 | when green flag clicked 1017 | forever 1018 | if <(Previewing)=[1]> 1019 | hide 1020 | else 1021 | show 1022 | go to x:(-36) y:(170) 1023 | switch to costume ((Selected) + (1)) 1024 | if <<<(mouse y) > [156]> and <(mouse y) < [180]>> and <(mouse x) < [50]>> 1025 | set [brightness v] effect to (-5) 1026 | else 1027 | set [brightness v] effect to (-50) 1028 | end 1029 | end 1030 | end 1031 | 1032 | 1033 | when green flag clicked 1034 | go to x:(105) y:(170) 1035 | forever 1036 | switch to costume [maps v] 1037 | if <(Previewing)=[1]> 1038 | switch to costume [maps_hover v] 1039 | set [brightness v] effect to (-50) 1040 | wait until > 1041 | if [156]> and <(mouse y) < [180]>> and <<(mouse x) > [55]> and <(mouse x) < [122]>>>> 1042 | switch to costume [maps v] 1043 | repeat (20) 1044 | change [brightness v] effect by (2.5) 1045 | end 1046 | end 1047 | end 1048 | if <<([processing v] of [placer v])=[0]> and <<<(mouse y) > [156]> and <(mouse y) < [180]>> and <<(mouse x) > [55]> and <(mouse x) < [122]>>>> 1049 | switch to costume [maps_hover v] 1050 | set [brightness v] effect to (-50) 1051 | if 1052 | say [] 1053 | set [brightness v] effect to (0) 1054 | wait until > 1055 | set [brightness v] effect to (-50) 1056 | broadcast [Previews v] 1057 | wait until <(Previewing)=[1]> 1058 | wait until <(Previewing)=[0]> 1059 | if [156]> and <(mouse y) < [180]>> and <<(mouse x) > [55]> and <(mouse x) < [122]>>>> 1060 | switch to costume [maps v] 1061 | repeat (20) 1062 | change [brightness v] effect by (2.5) 1063 | end 1064 | end 1065 | end 1066 | else 1067 | say [] 1068 | switch to costume [maps v] 1069 | set [brightness v] effect to (0) 1070 | end 1071 | end 1072 | 1073 | 1074 | say (join [Current: ] (item (Level) of [Level Names v])) 1075 | 1076 | 1077 | when green flag clicked 1078 | go to x:(165) y:(170) 1079 | forever 1080 | switch to costume [Offline v] 1081 | if <<<([processing v] of [placer v])=[0]> and <(Previewing)=[0]>> and <<<(mouse y) > [156]> and <(mouse y) < [180]>> and <<(mouse x) > [122]> and <(mouse x) < [180]>>>> 1082 | switch to costume [help_hover v] 1083 | if <(Previewing)=[0]> 1084 | set [brightness v] effect to (-50) 1085 | if 1086 | set [brightness v] effect to (0) 1087 | wait until > 1088 | set [brightness v] effect to (-50) 1089 | broadcast [Instructions v] and wait 1090 | if [156]> and <(mouse y) < [180]>> and <<(mouse x) > [122]> and <(mouse x) < [180]>>>> 1091 | switch to costume [help v] 1092 | repeat (20) 1093 | change [brightness v] effect by (2.5) 1094 | end 1095 | end 1096 | end 1097 | end 1098 | else 1099 | switch to costume [help v] 1100 | set [brightness v] effect to (0) 1101 | end 1102 | end 1103 | 1104 | 1105 | when green flag clicked 1106 | set [isOnline v] to [1] 1107 | if <(join (yourself) [])=[a ScratchSpriteMorph()]> 1108 | set [isOnline v] to [0] 1109 | end 1110 | 1111 | 1112 | when green flag clicked 1113 | wait (0.5) secs 1114 | go to x:(235) y:(170) 1115 | switch to costume ((isOnline) + (1)) 1116 | 1117 | 1118 | when green flag clicked 1119 | go to x:(0) y:(0) 1120 | hide 1121 | 1122 | 1123 | broadcast [_instructions v] and wait 1124 | 1125 | 1126 | when green flag clicked 1127 | forever 1128 | go to front 1129 | end 1130 | 1131 | 1132 | when I receive [Instructions v] 1133 | broadcast [Stop v] 1134 | clear graphic effects 1135 | set [ghost v] effect to (100) 1136 | set [pixelate v] effect to (100) 1137 | show 1138 | repeat (20) 1139 | change [pixelate v] effect by (-5) 1140 | change [ghost v] effect by (-4) 1141 | end 1142 | broadcast [_instructions v] and wait 1143 | 1144 | 1145 | when I receive [_instructions v] 1146 | clear graphic effects 1147 | set [ghost v] effect to (20) 1148 | show 1149 | wait until > 1150 | wait until 1151 | repeat (20) 1152 | change [pixelate v] effect by (5) 1153 | change [ghost v] effect by (4) 1154 | end 1155 | hide 1156 | broadcast [Start v] 1157 | wait (0) secs 1158 | broadcast [Drive v] 1159 | 1160 | 1161 | when green flag clicked 1162 | go to x:(0) y:(0) 1163 | hide 1164 | 1165 | 1166 | when I receive [New Level v] 1167 | 1168 | 1169 | wait until <([processing v] of [placer v])=[1]> 1170 | set [color v] effect to (130) 1171 | set [brightness v] effect to (50) 1172 | switch to costume [building v] 1173 | show 1174 | wait until <([processing v] of [placer v])=[0]> 1175 | hide 1176 | 1177 | 1178 | when I receive [New Level v] 1179 | 1180 | 1181 | wait until <([processing v] of [placer v])=[1]> 1182 | set [color v] effect to (130) 1183 | set [brightness v] effect to (50) 1184 | repeat until <([processing v] of [placer v])=[0]> 1185 | go to front 1186 | set size to (150)% 1187 | repeat (2) 1188 | wait (0.25) secs 1189 | set [brightness v] effect to (0) 1190 | wait (0.25) secs 1191 | set [brightness v] effect to (85) 1192 | change size by (50) 1193 | end 1194 | wait (0.25) secs 1195 | set [brightness v] effect to (0) 1196 | wait (0.25) secs 1197 | set [brightness v] effect to (85) 1198 | end 1199 | 1200 | 1201 | when I receive [Refresh All v] 1202 | wait until <([processing v] of [placer v])=[1]> 1203 | set [color v] effect to (130) 1204 | set [brightness v] effect to (50) 1205 | switch to costume [building v] 1206 | show 1207 | wait until <([processing v] of [placer v])=[0]> 1208 | hide 1209 | 1210 | 1211 | when I receive [Refresh All v] 1212 | wait until <([processing v] of [placer v])=[1]> 1213 | set [color v] effect to (130) 1214 | set [brightness v] effect to (50) 1215 | repeat until <([processing v] of [placer v])=[0]> 1216 | go to front 1217 | set size to (150)% 1218 | repeat (2) 1219 | wait (0.25) secs 1220 | set [brightness v] effect to (0) 1221 | wait (0.25) secs 1222 | set [brightness v] effect to (85) 1223 | change size by (50) 1224 | end 1225 | wait (0.25) secs 1226 | set [brightness v] effect to (0) 1227 | wait (0.25) secs 1228 | set [brightness v] effect to (85) 1229 | end 1230 | 1231 | 1232 | when I receive [Thinking v] 1233 | wait until <([processing v] of [placer v])=[1]> 1234 | set [color v] effect to (115) 1235 | set [brightness v] effect to (100) 1236 | switch to costume [thinking v] 1237 | show 1238 | wait until <([processing v] of [placer v])=[0]> 1239 | hide 1240 | 1241 | 1242 | when I receive [Thinking v] 1243 | wait until <([processing v] of [placer v])=[1]> 1244 | set [color v] effect to (115) 1245 | set [brightness v] effect to (100) 1246 | repeat until <([processing v] of [placer v])=[0]> 1247 | go to front 1248 | set size to (150)% 1249 | repeat (2) 1250 | wait (0.25) secs 1251 | set [brightness v] effect to (0) 1252 | wait (0.25) secs 1253 | set [brightness v] effect to (100) 1254 | change size by (50) 1255 | end 1256 | wait (0.25) secs 1257 | set [brightness v] effect to (0) 1258 | wait (0.25) secs 1259 | set [brightness v] effect to (100) 1260 | end 1261 | 1262 | 1263 | when I receive [Delete Level v] 1264 | wait until <([processing v] of [asker v])=[1]> 1265 | set [color v] effect to (199) 1266 | set [brightness v] effect to (90) 1267 | switch to costume [destroying v] 1268 | show 1269 | wait until <([processing v] of [asker v])=[0]> 1270 | hide 1271 | 1272 | 1273 | when I receive [Delete Level v] 1274 | wait until <([processing v] of [asker v])=[1]> 1275 | set [color v] effect to (199) 1276 | set [brightness v] effect to (90) 1277 | switch to costume [destroying v] 1278 | show 1279 | repeat until <([processing v] of [asker v])=[0]> 1280 | go to front 1281 | set size to (150)% 1282 | repeat (2) 1283 | wait (0.25) secs 1284 | set [brightness v] effect to (0) 1285 | wait (0.25) secs 1286 | set [brightness v] effect to (100) 1287 | change size by (50) 1288 | end 1289 | wait (0.25) secs 1290 | set [brightness v] effect to (0) 1291 | wait (0.25) secs 1292 | set [brightness v] effect to (100) 1293 | end 1294 | 1295 | 1296 | when I receive [Drive v] 1297 | set [train v] to (join [train] [2]) 1298 | repeat until <([processing v] of [placer v])=[1]> 1299 | set [d v] to (((direction) + (45)) mod (360)) 1300 | if <<<(d) < [15]> or <(d) > [345]>> or <<(d) > [165]> and <(d) < [195]>>> 1301 | switch to costume [top v] 1302 | else 1303 | if <(d) < [180]> 1304 | if <<(d) < [40]> or <(d) > [140]>> 1305 | switch to costume [normal1 v] 1306 | else 1307 | switch to costume [normal v] 1308 | end 1309 | else 1310 | if <<(d) < [220]> or <(d) > [320]>> 1311 | switch to costume [flipped1 v] 1312 | else 1313 | switch to costume [flipped v] 1314 | end 1315 | end 1316 | end 1317 | end 1318 | 1319 | 1320 | when I receive [Hide Cars v] 1321 | hide 1322 | clear graphic effects 1323 | wait (1.2) secs 1324 | hide 1325 | clear graphic effects 1326 | 1327 | 1328 | when I receive [train2.next v] 1329 | change [tx v] by ([sin v] of (next dir)) 1330 | change [ty v] by ([cos v] of (next dir)) 1331 | set [next dir v] to ((next dir) mod (360)) 1332 | set [Choices v] to [0] 1333 | set [_choices v] to [0] 1334 | set [d i v] to [0] 1335 | set [_tx v] to (round (tx)) 1336 | set [_ty v] to (round (ty)) 1337 | set [_ti v] to (((_tx) + ((_ty) * (20))) + (Level_index)) 1338 | if <<(item (_ti) of [Tiles v])=[3]> and <<<(item (_ti) of [Tile Surroundings.1 v])=[6]> and <(item (_ti) of [Tile Surroundings.2 v])=[11]>> or <<(item (_ti) of [Tile Surroundings.1 v])=[11]> and <(item (_ti) of [Tile Surroundings.2 v])=[6]>>>> 1339 | set [Choices v] to [0] 1340 | if > 1341 | set [crossing.tx v] to (_tx) 1342 | set [crossing.ty v] to (_ty) 1343 | set [crossing.requestType v] to [2] 1344 | broadcast [Crossing Request v] 1345 | stop script 1346 | end 1347 | end 1348 | repeat (4) 1349 | change [d i v] by (1) 1350 | replace item (d i) of [Directions v] with [0] 1351 | set [_current tx v] to (round ((_tx) + ([sin v] of (next dir)))) 1352 | set [_current ty v] to (round ((_ty) + ([cos v] of (next dir)))) 1353 | if <<<(_current tx) > [-1]> and <(_current ty) > [-1]>> and <<(_current tx) < [20]> and <(_current ty) < [14]>>> 1354 | set [tile v] to (item (((_current tx) + ((_current ty) * (20))) + (Level_index)) of [Tiles v]) 1355 | if <<(tile)=[2]> or <(tile)=[3]>> 1356 | change [_choices v] by (1) 1357 | replace item (d i) of [Directions v] with [1] 1358 | end 1359 | end 1360 | change [next dir v] by (90) 1361 | end 1362 | set [Choices v] to (_choices) 1363 | 1364 | 1365 | when I receive [Reset Vehicles v] 1366 | set [ready v] to [0] 1367 | hide 1368 | go to x:(0) y:(0) 1369 | point in direction (-90 v) 1370 | set [ghost v] effect to (100) 1371 | set [color v] effect to (60) 1372 | wait (1) secs 1373 | show 1374 | go to front 1375 | repeat (2) 1376 | repeat (25) 1377 | change [ghost v] effect by (-2) 1378 | end 1379 | wait (0.5) secs 1380 | repeat (25) 1381 | change [ghost v] effect by (2) 1382 | end 1383 | wait (0.5) secs 1384 | end 1385 | repeat (10) 1386 | change [ghost v] effect by (-10) 1387 | end 1388 | set [ready v] to [1] 1389 | 1390 | 1391 | when I receive [Drive v] 1392 | wait until <(ready)=[1]> 1393 | show 1394 | set [ghost v] effect to (0) 1395 | go to front 1396 | set [Choices v] to [0] 1397 | repeat until <([processing v] of [placer v])=[1]> 1398 | point in direction (((direction) + (45)) - (((direction) + (45)) mod (90))) 1399 | set [nx v] to ((x position) + (([sin v] of (direction)) * (12))) 1400 | set [ny v] to ((y position) + (([cos v] of (direction)) * (12))) 1401 | set [tx v] to ((((nx) - (12)) / (24)) + (10)) 1402 | set [ty v] to (((ny) / (24)) + (7)) 1403 | if <(Choices)=[0]> 1404 | set [next dir v] to (direction) 1405 | change [tx v] by ((0) - ([sin v] of (direction))) 1406 | change [ty v] by ((0) - ([cos v] of (direction))) 1407 | broadcast (join (train) [.next]) and wait 1408 | set [tx v] to ((((nx) - (12)) / (24)) + (10)) 1409 | set [ty v] to (((ny) / (24)) + (7)) 1410 | end 1411 | if <(Choices)=[4]> 1412 | set [Choice v] to [1] 1413 | else 1414 | if <<(Choices)=[1]> and <(item (3 v) of [Directions v])=[1]>> 1415 | set [Choice v] to [3] 1416 | else 1417 | change [Choices v] by (-1) 1418 | if <(Choices)=[1]> 1419 | if <(item (1 v) of [Directions v])=[1]> 1420 | set [Choice v] to [1] 1421 | else 1422 | if <(item (2 v) of [Directions v])=[1]> 1423 | set [Choice v] to [2] 1424 | else 1425 | set [Choice v] to [4] 1426 | end 1427 | end 1428 | else 1429 | if <(Choices)=[2]> 1430 | if <(item (round (((tx) + ((ty) * (20))) + (Level_index))) of [Tile Switches v])=[1]> 1431 | if <(item (1 v) of [Directions v])=[0]> 1432 | set [Choice v] to [4] 1433 | else 1434 | if <(item (2 v) of [Directions v])=[0]> 1435 | set [Choice v] to [1] 1436 | else 1437 | set [Choice v] to [2] 1438 | end 1439 | end 1440 | else 1441 | if <(item (1 v) of [Directions v])=[0]> 1442 | set [Choice v] to [2] 1443 | else 1444 | if <(item (2 v) of [Directions v])=[0]> 1445 | set [Choice v] to [4] 1446 | else 1447 | set [Choice v] to [1] 1448 | end 1449 | end 1450 | end 1451 | else 1452 | set [Choice v] to [0] 1453 | end 1454 | end 1455 | end 1456 | end 1457 | if <<<(item (_ti) of [Tiles v])=[3]> and >> and <<<(item (_ti) of [Tile Surroundings.1 v])=[6]> and <(item (_ti) of [Tile Surroundings.2 v])=[11]>> or <<(item (_ti) of [Tile Surroundings.1 v])=[11]> and <(item (_ti) of [Tile Surroundings.2 v])=[6]>>>> 1458 | set [crossing.tx v] to (_tx) 1459 | set [crossing.ty v] to (_ty) 1460 | set [crossing.requestType v] to [2] 1461 | broadcast [Crossing Request v] 1462 | set [Choice v] to [0] 1463 | else 1464 | if <(Choice)=[1]> 1465 | set [next dir v] to (direction) 1466 | broadcast (join (train) [.next]) 1467 | repeat (24) 1468 | move (1) steps 1469 | end 1470 | end 1471 | if <(Choice)=[2]> 1472 | set [next dir v] to ((direction) + (90)) 1473 | broadcast (join (train) [.next]) 1474 | set [rx v] to ((x position) + (([sin v] of ((direction) + (90))) * (12))) 1475 | set [ry v] to ((y position) + (([cos v] of ((direction) + (90))) * (12))) 1476 | repeat (18) 1477 | turn cw (5) degrees 1478 | go to x:((rx) + (([sin v] of ((direction) - (90))) * (12))) y:((([cos v] of ((direction) - (90))) * (12)) + (ry)) 1479 | end 1480 | end 1481 | if <(Choice)=[3]> 1482 | set [next dir v] to ((direction) + (180)) 1483 | repeat (16) 1484 | move (0.5) steps 1485 | end 1486 | turn cw (180) degrees 1487 | if <(((direction) + (45)) mod (360)) < [180]> 1488 | switch to costume [normal v] 1489 | else 1490 | switch to costume [flipped v] 1491 | end 1492 | broadcast (join (train) [.next]) and wait 1493 | repeat (16) 1494 | move (0.5) steps 1495 | end 1496 | end 1497 | if <(Choice)=[4]> 1498 | set [next dir v] to ((direction) - (90)) 1499 | broadcast (join (train) [.next]) 1500 | set [rx v] to ((x position) + (([sin v] of ((direction) - (90))) * (12))) 1501 | set [ry v] to ((y position) + (([cos v] of ((direction) - (90))) * (12))) 1502 | repeat (18) 1503 | turn ccw (5) degrees 1504 | go to x:((rx) + (([sin v] of ((direction) + (90))) * (12))) y:((([cos v] of ((direction) + (90))) * (12)) + (ry)) 1505 | end 1506 | end 1507 | end 1508 | if <(Choice)=[0]> 1509 | set [Choices v] to [0] 1510 | end 1511 | end 1512 | 1513 | 1514 | go to x:(((x position) - ((x position) mod (24))) + (12)) y:(((y position) - (((y position) + (12)) mod (24))) + (12)) 1515 | point in direction (((direction) + (45)) - (((direction) + (45)) mod (90))) 1516 | move (12) steps 1517 | 1518 | 1519 | when I receive [Drive v] 1520 | set [car v] to (join [car] [2]) 1521 | repeat until <([processing v] of [placer v])=[1]> 1522 | set [d v] to (((direction) + (45)) mod (360)) 1523 | if <(d) < [180]> 1524 | switch to costume [normal v] 1525 | else 1526 | switch to costume [flipped v] 1527 | end 1528 | end 1529 | 1530 | 1531 | when I receive [Hide Cars v] 1532 | hide 1533 | clear graphic effects 1534 | set [Choice v] to [0] 1535 | 1536 | 1537 | when I receive [car2.next v] 1538 | change [tx v] by ([sin v] of (next dir)) 1539 | change [ty v] by ([cos v] of (next dir)) 1540 | set [next dir v] to ((next dir) mod (360)) 1541 | set [Choices v] to [0] 1542 | set [_choices v] to [0] 1543 | set [d i v] to [0] 1544 | set [_tx v] to (round (tx)) 1545 | set [_ty v] to (round (ty)) 1546 | set [_ti v] to (((_tx) + ((_ty) * (20))) + (Level_index)) 1547 | if <<(item (_ti) of [Tiles v])=[3]> and <<<(item (_ti) of [Tile Surroundings.1 v])=[6]> and <(item (_ti) of [Tile Surroundings.2 v])=[11]>> or <<(item (_ti) of [Tile Surroundings.1 v])=[11]> and <(item (_ti) of [Tile Surroundings.2 v])=[6]>>>> 1548 | if > 1549 | set [Choices v] to [0] 1550 | replace item (1 v) of [Directions v] with [0] 1551 | replace item (2 v) of [Directions v] with [0] 1552 | replace item (3 v) of [Directions v] with [0] 1553 | replace item (4 v) of [Directions v] with [0] 1554 | set [crossing.tx v] to (_tx) 1555 | set [crossing.ty v] to (_ty) 1556 | set [crossing.requestType v] to [1] 1557 | broadcast [Crossing Request v] 1558 | stop script 1559 | end 1560 | end 1561 | repeat (4) 1562 | change [d i v] by (1) 1563 | replace item (d i) of [Directions v] with [0] 1564 | set [_current tx v] to (round ((_tx) + ([sin v] of (next dir)))) 1565 | set [_current ty v] to (round ((_ty) + ([cos v] of (next dir)))) 1566 | if <<<(_current tx) > [-1]> and <(_current ty) > [-1]>> and <<(_current tx) < [20]> and <(_current ty) < [14]>>> 1567 | set [tile v] to (item (((_current tx) + ((_current ty) * (20))) + (Level_index)) of [Tiles v]) 1568 | if <<(tile)=[1]> or <(tile)=[3]>> 1569 | change [_choices v] by (1) 1570 | replace item (d i) of [Directions v] with [1] 1571 | if > 1572 | set [_choice v] to (d i) 1573 | end 1574 | end 1575 | end 1576 | change [next dir v] by (90) 1577 | end 1578 | set [Choices v] to (_choices) 1579 | 1580 | 1581 | when I receive [Reset Vehicles v] 1582 | set [ready v] to [0] 1583 | go to x:(4) y:(-28) 1584 | point in direction (-90 v) 1585 | set [color v] effect to (110) 1586 | show 1587 | go to front 1588 | set [ghost v] effect to (100) 1589 | repeat (10) 1590 | change [ghost v] effect by (-10) 1591 | end 1592 | set [ready v] to [1] 1593 | 1594 | 1595 | when I receive [Drive v] 1596 | wait until <(ready)=[1]> 1597 | show 1598 | set [ghost v] effect to (0) 1599 | go to front 1600 | set [Choices v] to [0] 1601 | repeat until <([processing v] of [placer v])=[1]> 1602 | point in direction (round (((direction) + (45)) - (((direction) + (45)) mod (90)))) 1603 | set [nx v] to ((x position) + ((([sin v] of (direction)) * (16)) + (([sin v] of ((direction) + (90))) * (4)))) 1604 | set [ny v] to ((y position) + ((([cos v] of (direction)) * (16)) + (([cos v] of ((direction) + (90))) * (4)))) 1605 | set [tx v] to ((((nx) - (12)) / (24)) + (10)) 1606 | set [ty v] to (((ny) / (24)) + (7)) 1607 | if <(Choices)=[0]> 1608 | set [next dir v] to (direction) 1609 | change [tx v] by ((0) - ([sin v] of (direction))) 1610 | change [ty v] by ((0) - ([cos v] of (direction))) 1611 | broadcast (join (car) [.next]) and wait 1612 | set [tx v] to ((((nx) - (12)) / (24)) + (10)) 1613 | set [ty v] to (((ny) / (24)) + (7)) 1614 | end 1615 | if <<(Choices)=[1]> and <(item (3 v) of [Directions v])=[1]>> 1616 | set [Choice v] to [3] 1617 | else 1618 | if <(item (3 v) of [Directions v])=[1]> 1619 | change [Choices v] by (-1) 1620 | end 1621 | if <(Choices)=[1]> 1622 | set [Choice v] to (_choice) 1623 | else 1624 | set [Choice v] to [] 1625 | repeat until <> or <(Choices)=[0]>> 1626 | if 1627 | set [Choice v] to ((0) - (direction)) 1628 | end 1629 | if 1630 | set [Choice v] to ((90) - (direction)) 1631 | end 1632 | if 1633 | set [Choice v] to ((180) - (direction)) 1634 | end 1635 | if 1636 | set [Choice v] to ((270) - (direction)) 1637 | end 1638 | if > 1639 | set [Choice v] to ((round ((((Choice) + (0)) mod (360)) / (90))) + (1)) 1640 | if <(item (Choice) of [Directions v])=[0]> 1641 | set [Choice v] to [] 1642 | end 1643 | end 1644 | end 1645 | if <(Choices)=[]> 1646 | set [Choice v] to [0] 1647 | end 1648 | end 1649 | end 1650 | if <<<(item (_ti) of [Tiles v])=[3]> and >> and <<<(item (_ti) of [Tile Surroundings.1 v])=[6]> and <(item (_ti) of [Tile Surroundings.2 v])=[11]>> or <<(item (_ti) of [Tile Surroundings.1 v])=[11]> and <(item (_ti) of [Tile Surroundings.2 v])=[6]>>>> 1651 | set [crossing.tx v] to (_tx) 1652 | set [crossing.ty v] to (_ty) 1653 | set [crossing.requestType v] to [1] 1654 | broadcast [Crossing Request v] 1655 | set [Choice v] to [0] 1656 | else 1657 | if <(Choice)=[1]> 1658 | set [next dir v] to (direction) 1659 | broadcast (join (car) [.next]) 1660 | repeat (24) 1661 | move (1) steps 1662 | end 1663 | end 1664 | if <(Choice)=[2]> 1665 | set [next dir v] to ((direction) + (90)) 1666 | broadcast (join (car) [.next]) 1667 | repeat (8) 1668 | move (1) steps 1669 | end 1670 | set [rx v] to ((x position) + (([sin v] of ((direction) + (90))) * (12))) 1671 | set [ry v] to ((y position) + (([cos v] of ((direction) + (90))) * (12))) 1672 | repeat (18) 1673 | turn cw (5) degrees 1674 | go to x:((rx) + (([sin v] of ((direction) - (90))) * (12))) y:((([cos v] of ((direction) - (90))) * (12)) + (ry)) 1675 | end 1676 | end 1677 | if <(Choice)=[3]> 1678 | set [next dir v] to ((direction) + (180)) 1679 | broadcast (join (car) [.next]) 1680 | repeat (16) 1681 | move (1) steps 1682 | end 1683 | set [rx v] to ((x position) + (([sin v] of ((direction) + (90))) * (4))) 1684 | set [ry v] to ((y position) + (([cos v] of ((direction) + (90))) * (4))) 1685 | repeat (18) 1686 | turn cw (10) degrees 1687 | go to x:((rx) + (([sin v] of ((direction) - (90))) * (4))) y:((([cos v] of ((direction) - (90))) * (4)) + (ry)) 1688 | end 1689 | repeat (8) 1690 | move (1) steps 1691 | end 1692 | end 1693 | if <(Choice)=[4]> 1694 | set [next dir v] to ((direction) - (90)) 1695 | broadcast (join (car) [.next]) 1696 | repeat (8) 1697 | move (1) steps 1698 | end 1699 | set [rx v] to ((x position) + (([sin v] of ((direction) - (90))) * (4))) 1700 | set [ry v] to ((y position) + (([cos v] of ((direction) - (90))) * (4))) 1701 | repeat (9) 1702 | turn ccw (10) degrees 1703 | go to x:((rx) + (([sin v] of ((direction) + (90))) * (4))) y:((([cos v] of ((direction) + (90))) * (4)) + (ry)) 1704 | end 1705 | end 1706 | end 1707 | if <(Choice)=[0]> 1708 | set [Choices v] to [0] 1709 | end 1710 | end 1711 | 1712 | 1713 | clear graphic effects 1714 | go to x:(-88) y:(-112) 1715 | point in direction (0 v) 1716 | repeat (4) 1717 | move (1) steps 1718 | end 1719 | repeat (4) 1720 | move (1) steps 1721 | change [ghost v] effect by (25) 1722 | end 1723 | wait (1) secs 1724 | go to x:(-80) y:(-102) 1725 | point in direction (180 v) 1726 | repeat (4) 1727 | move (1) steps 1728 | change [ghost v] effect by (-25) 1729 | end 1730 | repeat (4) 1731 | move (1) steps 1732 | end 1733 | 1734 | 1735 | when green flag clicked 1736 | hide 1737 | 1738 | 1739 | when I receive [Drive v] 1740 | set [car v] to (join [car] [2]) 1741 | set [ghost v] effect to (25) 1742 | forever 1743 | go to x:(((([tx v] of (car)) - (10)) * (24)) + (12)) y:((([ty v] of (car)) - (7)) * (24)) 1744 | if <<([Choice v] of (car))=[]> and <([Choices v] of (car)) > [1]>> 1745 | show 1746 | else 1747 | hide 1748 | end 1749 | end 1750 | 1751 | 1752 | when green flag clicked 1753 | hide 1754 | set [processing v] to [0] 1755 | 1756 | 1757 | when I receive [Previews v] 1758 | set [Previewing v] to [1] 1759 | set [processing v] to [1] 1760 | clear 1761 | hide 1762 | broadcast [Hide Cars v] 1763 | broadcast [SuperClear v] and wait 1764 | broadcast [Stop v] and wait 1765 | set [level v] to [1] 1766 | set y to (141) 1767 | repeat (5) 1768 | set x to (-230) 1769 | if <((level) - (1)) < (Levels)> 1770 | change [level v] by (1) 1771 | else 1772 | switch to costume [add v] 1773 | stamp 1774 | broadcast [Draw Previews v] 1775 | stop script 1776 | end 1777 | switch to costume [drawing v] 1778 | stamp 1779 | change x by (80) 1780 | if <((level) - (1)) < (Levels)> 1781 | change [level v] by (1) 1782 | else 1783 | switch to costume [add v] 1784 | stamp 1785 | broadcast [Draw Previews v] 1786 | stop script 1787 | end 1788 | switch to costume [drawing v] 1789 | stamp 1790 | change x by (80) 1791 | if <((level) - (1)) < (Levels)> 1792 | change [level v] by (1) 1793 | else 1794 | switch to costume [add v] 1795 | stamp 1796 | broadcast [Draw Previews v] 1797 | stop script 1798 | end 1799 | switch to costume [drawing v] 1800 | stamp 1801 | change x by (80) 1802 | if <((level) - (1)) < (Levels)> 1803 | change [level v] by (1) 1804 | else 1805 | switch to costume [add v] 1806 | stamp 1807 | broadcast [Draw Previews v] 1808 | stop script 1809 | end 1810 | switch to costume [drawing v] 1811 | stamp 1812 | change x by (80) 1813 | if <((level) - (1)) < (Levels)> 1814 | change [level v] by (1) 1815 | else 1816 | switch to costume [add v] 1817 | stamp 1818 | broadcast [Draw Previews v] 1819 | stop script 1820 | end 1821 | switch to costume [drawing v] 1822 | stamp 1823 | change x by (80) 1824 | if <((level) - (1)) < (Levels)> 1825 | change [level v] by (1) 1826 | else 1827 | switch to costume [add v] 1828 | stamp 1829 | broadcast [Draw Previews v] 1830 | stop script 1831 | end 1832 | switch to costume [drawing v] 1833 | stamp 1834 | change x by (80) 1835 | change y by (-62) 1836 | end 1837 | 1838 | 1839 | when I receive [Draw Previews v] 1840 | set [level v] to [1] 1841 | set [tile_index v] to [1] 1842 | set y to (141) 1843 | repeat (5) 1844 | set x to (-230) 1845 | repeat (6) 1846 | if <(Previewing)=[0]> 1847 | set [processing v] to [0] 1848 | stop script 1849 | end 1850 | if <((level) - (1)) < (Levels)> 1851 | change [level v] by (1) 1852 | else 1853 | set [processing v] to [0] 1854 | stop script 1855 | end 1856 | change x by (1) 1857 | change y by (-41) 1858 | repeat (14) 1859 | repeat (20) 1860 | switch to costume ((item (tile_index) of [Tiles v]) + (1)) 1861 | stamp 1862 | change x by (3) 1863 | change [tile_index v] by (1) 1864 | end 1865 | 1866 | change x by (-60) 1867 | change y by (3) 1868 | end 1869 | change x by (-1) 1870 | change y by (-1) 1871 | change x by (80) 1872 | end 1873 | change y by (-62) 1874 | end 1875 | set [processing v] to [0] 1876 | 1877 | 1878 | when green flag clicked 1879 | hide 1880 | set [visible v] to [0] 1881 | set [ghost v] to [0] 1882 | 1883 | 1884 | when I receive [Previews v] 1885 | set [Previewing v] to [1] 1886 | repeat until <(Previewing)=[0]> 1887 | wait until <([blocking v] of [prvtool v])=[0]> 1888 | if <<<(mouse y) > [-159]> and <(mouse y) < [151]>> and <<(mouse x) > [-240]> and <(mouse x) < [240]>>> 1889 | go to x:(((mouse x) - ((mouse x) mod (80))) + (10)) y:(((mouse y) - (((mouse y) + (35)) mod (62))) + (51)) 1890 | set [selected level v] to ((((((x position) - (10)) / (80)) + (3)) + ((6) * ((2) - (((y position) - (16)) / (62))))) + (1)) 1891 | if <((selected level) - (2)) < (Levels)> 1892 | if <(selected level) > (Levels)> 1893 | switch to costume [gloss-new v] 1894 | else 1895 | switch to costume [gloss v] 1896 | end 1897 | set [ghost v] effect to (100) 1898 | set [ghost v] to [100] 1899 | show 1900 | if 1901 | set [visible v] to [1] 1902 | repeat until > 1903 | say (item (selected level) of [Level Names v]) 1904 | if <([blocking v] of [prvtool v])=[1]> 1905 | say [] 1906 | wait until <<([blocking v] of [prvtool v])=[0]> or <(Previewing)=[0]>> 1907 | if <(Previewing)=[0]> 1908 | set [visible v] to [0] 1909 | hide 1910 | stop script 1911 | end 1912 | end 1913 | if 1914 | say [] 1915 | switch to costume [outline v] 1916 | wait until > 1917 | switch to costume [gloss v] 1918 | if < and <(mouse x) < ((x position) + (48))>> 1919 | set [visible v] to [0] 1920 | hide 1921 | set [Level v] to (selected level) 1922 | if <(selected level) > (Levels)> 1923 | broadcast [New Level - Choose v] and wait 1924 | else 1925 | set [Previewing v] to [0] 1926 | wait until <([processing v] of [prv v])=[0]> 1927 | broadcast [Load Level v] 1928 | set [visible v] to [0] 1929 | stop script 1930 | end 1931 | end 1932 | end 1933 | end 1934 | say [] 1935 | set [visible v] to [0] 1936 | end 1937 | else 1938 | hide 1939 | set [visible v] to [0] 1940 | end 1941 | else 1942 | hide 1943 | set [visible v] to [0] 1944 | end 1945 | end 1946 | hide 1947 | 1948 | 1949 | when I receive [Previews v] 1950 | set [Previewing v] to [1] 1951 | repeat until <(Previewing)=[0]> 1952 | if <(visible)=[1]> 1953 | show 1954 | if <(ghost) > [50]> 1955 | change [ghost v] effect by (-10) 1956 | change [ghost v] by (-10) 1957 | end 1958 | else 1959 | hide 1960 | if <(ghost) < [100]> 1961 | change [ghost v] effect by (10) 1962 | change [ghost v] by (10) 1963 | end 1964 | end 1965 | end 1966 | 1967 | 1968 | wait until <(visible)=[1]> 1969 | set [ghost v] effect to (100) 1970 | repeat (5) 1971 | end 1972 | wait until <(visible)=[0]> 1973 | repeat (5) 1974 | change [ghost v] effect by (10) 1975 | end 1976 | 1977 | 1978 | when green flag clicked 1979 | hide 1980 | clear graphic effects 1981 | set [blocking v] to [0] 1982 | 1983 | 1984 | when I receive [Previews v] 1985 | set [Previewing v] to [1] 1986 | set [blocking v] to [0] 1987 | repeat until <(Previewing)=[0]> 1988 | wait until <(blocking)=[0]> 1989 | go to [prvhvr v] 1990 | if <<([visible v] of [prvhvr v])=[1]> and <(([selected level v] of [prvhvr v]) - (1)) < (Levels)>> 1991 | if <<(mouse x) > (([x position v] of [prvhvr v]) + (48))> and <(mouse y) < (([y position v] of [prvhvr v]) - (8))>> 1992 | set [y v] to ((([y position v] of [prvhvr v]) - (8)) - (mouse y)) 1993 | switch to costume ((((y) - ((y) mod (11))) / (11)) + (2)) 1994 | if 1995 | set [blocking v] to [1] 1996 | set [selected_level v] to ([selected level v] of [prvhvr v]) 1997 | change y by (-1) 1998 | wait until > 1999 | change y by (1) 2000 | if <(costume #)=[2]> 2001 | switch to costume [tools1 v] 2002 | broadcast [Delete Level - Prompt v] and wait 2003 | end 2004 | if <(costume #)=[3]> 2005 | switch to costume [tools1 v] 2006 | broadcast [Rename Level v] and wait 2007 | end 2008 | if <(costume #)=[4]> 2009 | set [Level v] to (selected_level) 2010 | switch to costume [tools1 v] 2011 | broadcast [Export v] and wait 2012 | end 2013 | set [blocking v] to [0] 2014 | end 2015 | else 2016 | switch to costume [tools1 v] 2017 | end 2018 | end 2019 | end 2020 | 2021 | 2022 | when I receive [Previews v] 2023 | set [Previewing v] to [1] 2024 | repeat until <(Previewing)=[0]> 2025 | if <<([visible v] of [prvhvr v])=[1]> and <(([selected level v] of [prvhvr v]) - (1)) < (Levels)>> 2026 | show 2027 | if <(ghost) > [0]> 2028 | change [ghost v] effect by (-10) 2029 | change [ghost v] by (-10) 2030 | end 2031 | else 2032 | hide 2033 | if <(ghost) < [100]> 2034 | change [ghost v] effect by (10) 2035 | change [ghost v] by (10) 2036 | end 2037 | end 2038 | end 2039 | hide 2040 | 2041 | 2042 | when I receive [New Level - Choose v] 2043 | set [blocking v] to [1] 2044 | 2045 | 2046 | when I receive [Import Level Prompt v] 2047 | set [blocking v] to [1] 2048 | broadcast [Import Code v] and wait 2049 | set [blocking v] to [0] 2050 | broadcast [Previews v] 2051 | 2052 | 2053 | when I receive [Continue Previewing v] 2054 | set [blocking v] to [0] 2055 | 2056 | 2057 | when green flag clicked 2058 | hide 2059 | 2060 | 2061 | when I receive [Rename Level v] 2062 | hide 2063 | set [selected_level v] to ([selected_level v] of [prvtool v]) 2064 | ask (join [Rename "] (join (item (selected_level) of [Level Names v]) [":])) and wait 2065 | if > 2066 | replace item (selected_level) of [Level Names v] with (answer) 2067 | end 2068 | 2069 | 2070 | when I receive [Delete Level - Prompt v] 2071 | hide 2072 | set [selected_level v] to ([selected_level v] of [prvtool v]) 2073 | ask (join [DELETE "] (join (item ([selected_level v] of [prvtool v]) of [Level Names v]) [" — are you sure? Type "delete" to confirm...])) and wait 2074 | if <(answer)=[delete]> 2075 | broadcast [Delete Level v] and wait 2076 | broadcast [Previews v] 2077 | end 2078 | 2079 | 2080 | when I receive [Delete Level v] 2081 | set [processing v] to [1] 2082 | set [tile_index v] to ((((selected_level) - (1)) * (280)) + (1)) 2083 | set [selected_level v] to [0] 2084 | repeat (14) 2085 | delete (tile_index) of [Tiles v] 2086 | delete (tile_index) of [Tile Switches v] 2087 | delete (tile_index) of [Tile Surroundings.1 v] 2088 | delete (tile_index) of [Tile Surroundings.2 v] 2089 | delete (tile_index) of [Tiles v] 2090 | delete (tile_index) of [Tile Switches v] 2091 | delete (tile_index) of [Tile Surroundings.1 v] 2092 | delete (tile_index) of [Tile Surroundings.2 v] 2093 | delete (tile_index) of [Tiles v] 2094 | delete (tile_index) of [Tile Switches v] 2095 | delete (tile_index) of [Tile Surroundings.1 v] 2096 | delete (tile_index) of [Tile Surroundings.2 v] 2097 | delete (tile_index) of [Tiles v] 2098 | delete (tile_index) of [Tile Switches v] 2099 | delete (tile_index) of [Tile Surroundings.1 v] 2100 | delete (tile_index) of [Tile Surroundings.2 v] 2101 | delete (tile_index) of [Tiles v] 2102 | delete (tile_index) of [Tile Switches v] 2103 | delete (tile_index) of [Tile Surroundings.1 v] 2104 | delete (tile_index) of [Tile Surroundings.2 v] 2105 | delete (tile_index) of [Tiles v] 2106 | delete (tile_index) of [Tile Switches v] 2107 | delete (tile_index) of [Tile Surroundings.1 v] 2108 | delete (tile_index) of [Tile Surroundings.2 v] 2109 | delete (tile_index) of [Tiles v] 2110 | delete (tile_index) of [Tile Switches v] 2111 | delete (tile_index) of [Tile Surroundings.1 v] 2112 | delete (tile_index) of [Tile Surroundings.2 v] 2113 | delete (tile_index) of [Tiles v] 2114 | delete (tile_index) of [Tile Switches v] 2115 | delete (tile_index) of [Tile Surroundings.1 v] 2116 | delete (tile_index) of [Tile Surroundings.2 v] 2117 | delete (tile_index) of [Tiles v] 2118 | delete (tile_index) of [Tile Switches v] 2119 | delete (tile_index) of [Tile Surroundings.1 v] 2120 | delete (tile_index) of [Tile Surroundings.2 v] 2121 | delete (tile_index) of [Tiles v] 2122 | delete (tile_index) of [Tile Switches v] 2123 | delete (tile_index) of [Tile Surroundings.1 v] 2124 | delete (tile_index) of [Tile Surroundings.2 v] 2125 | delete (tile_index) of [Tiles v] 2126 | delete (tile_index) of [Tile Switches v] 2127 | delete (tile_index) of [Tile Surroundings.1 v] 2128 | delete (tile_index) of [Tile Surroundings.2 v] 2129 | delete (tile_index) of [Tiles v] 2130 | delete (tile_index) of [Tile Switches v] 2131 | delete (tile_index) of [Tile Surroundings.1 v] 2132 | delete (tile_index) of [Tile Surroundings.2 v] 2133 | delete (tile_index) of [Tiles v] 2134 | delete (tile_index) of [Tile Switches v] 2135 | delete (tile_index) of [Tile Surroundings.1 v] 2136 | delete (tile_index) of [Tile Surroundings.2 v] 2137 | delete (tile_index) of [Tiles v] 2138 | delete (tile_index) of [Tile Switches v] 2139 | delete (tile_index) of [Tile Surroundings.1 v] 2140 | delete (tile_index) of [Tile Surroundings.2 v] 2141 | delete (tile_index) of [Tiles v] 2142 | delete (tile_index) of [Tile Switches v] 2143 | delete (tile_index) of [Tile Surroundings.1 v] 2144 | delete (tile_index) of [Tile Surroundings.2 v] 2145 | delete (tile_index) of [Tiles v] 2146 | delete (tile_index) of [Tile Switches v] 2147 | delete (tile_index) of [Tile Surroundings.1 v] 2148 | delete (tile_index) of [Tile Surroundings.2 v] 2149 | delete (tile_index) of [Tiles v] 2150 | delete (tile_index) of [Tile Switches v] 2151 | delete (tile_index) of [Tile Surroundings.1 v] 2152 | delete (tile_index) of [Tile Surroundings.2 v] 2153 | delete (tile_index) of [Tiles v] 2154 | delete (tile_index) of [Tile Switches v] 2155 | delete (tile_index) of [Tile Surroundings.1 v] 2156 | delete (tile_index) of [Tile Surroundings.2 v] 2157 | delete (tile_index) of [Tiles v] 2158 | delete (tile_index) of [Tile Switches v] 2159 | delete (tile_index) of [Tile Surroundings.1 v] 2160 | delete (tile_index) of [Tile Surroundings.2 v] 2161 | delete (tile_index) of [Tiles v] 2162 | delete (tile_index) of [Tile Switches v] 2163 | delete (tile_index) of [Tile Surroundings.1 v] 2164 | delete (tile_index) of [Tile Surroundings.2 v] 2165 | end 2166 | delete ([selected_level v] of [prvtool v]) of [Level Names v] 2167 | change [Levels v] by (-1) 2168 | set [processing v] to [0] 2169 | 2170 | 2171 | when green flag clicked 2172 | hide 2173 | clear graphic effects 2174 | 2175 | 2176 | when I receive [New Level - Choose v] 2177 | go to x:(0) y:(0) 2178 | clear graphic effects 2179 | show 2180 | set [Fill With v] to [0] 2181 | forever 2182 | if 2183 | if <<(mouse y) > [-8]> and <(mouse y) < [30]>> 2184 | switch to costume [blank v] 2185 | else 2186 | if <<(mouse y) > [-54]> and <(mouse y) < [-16]>> 2187 | switch to costume [trees v] 2188 | else 2189 | switch to costume [newmap v] 2190 | end 2191 | end 2192 | if <(costume #) > [1]> 2193 | if 2194 | set y to (-2) 2195 | wait until and >> 2196 | set y to (0) 2197 | if 2198 | set [Previewing v] to [0] 2199 | wait until <([processing v] of [prv v])=[0]> 2200 | if <(costume #)=[2]> 2201 | set [Fill With v] to [0] 2202 | end 2203 | if <(costume #)=[3]> 2204 | set [Fill With v] to [4] 2205 | end 2206 | broadcast [New Level v] 2207 | repeat (10) 2208 | change [ghost v] effect by (10) 2209 | end 2210 | hide 2211 | stop script 2212 | end 2213 | wait until > 2214 | end 2215 | end 2216 | else 2217 | switch to costume [newmap v] 2218 | if 2219 | set [brightness v] effect to (-5) 2220 | wait until > 2221 | set [brightness v] effect to (0) 2222 | broadcast [Continue Previewing v] 2223 | repeat (10) 2224 | change [ghost v] effect by (10) 2225 | end 2226 | hide 2227 | stop script 2228 | end 2229 | end 2230 | end 2231 | 2232 | 2233 | broadcast [Previews v] 2234 | 2235 | 2236 | when green flag clicked 2237 | hide 2238 | 2239 | 2240 | when I receive [Previews v] 2241 | go to x:(222) y:(-162) 2242 | set [ghost v] effect to (100) 2243 | switch to costume [load v] 2244 | show 2245 | repeat (10) 2246 | change [ghost v] effect by (-10) 2247 | end 2248 | repeat until <(Previewing)=[0]> 2249 | wait until <<([blocking v] of [prvtool v])=[0]> or <(Previewing)=[0]>> 2250 | if <<([abs v] of ((mouse x) - (x position))) < [12]> and <([abs v] of ((mouse y) - (y position))) < [12]>> 2251 | switch to costume [loadhover v] 2252 | if 2253 | change y by (-1) 2254 | wait until > 2255 | change y by (1) 2256 | if <(isOnline)=[1]> 2257 | broadcast [Download to import warning v] and wait 2258 | end 2259 | broadcast [Import Level Prompt v] and wait 2260 | end 2261 | else 2262 | switch to costume [load v] 2263 | end 2264 | end 2265 | hide 2266 | 2267 | 2268 | when green flag clicked 2269 | hide 2270 | 2271 | 2272 | when I receive [Export v] 2273 | if <(isOnline)=[1]> 2274 | broadcast [Must Download to export v] and wait 2275 | else 2276 | broadcast [Generate Code v] and wait 2277 | end 2278 | 2279 | 2280 | when I receive [Export instructions v] 2281 | set [shown v] to [1] 2282 | switch to costume [export1 v] 2283 | go to x:(-240) y:(180) 2284 | show 2285 | go to front 2286 | wait until 2287 | wait (1) secs 2288 | switch to costume [export2 v] 2289 | wait until <(shown)=[0]> 2290 | 2291 | 2292 | when [export v] clicked 2293 | hide 2294 | set [shown v] to [0] 2295 | 2296 | 2297 | when I receive [Must Download to export v] 2298 | switch to costume [downloadtoexport v] 2299 | go to x:(0) y:(0) 2300 | clear graphic effects 2301 | set [ghost v] effect to (100) 2302 | set [pixelate v] effect to (100) 2303 | show 2304 | repeat (20) 2305 | change [pixelate v] effect by (-5) 2306 | change [ghost v] effect by (-4) 2307 | end 2308 | wait until 2309 | repeat (20) 2310 | change [pixelate v] effect by (5) 2311 | change [ghost v] effect by (4) 2312 | end 2313 | hide 2314 | 2315 | 2316 | when I receive [Download to import warning v] 2317 | switch to costume [downloadtoimport v] 2318 | go to x:(0) y:(0) 2319 | clear graphic effects 2320 | set [ghost v] effect to (100) 2321 | set [pixelate v] effect to (100) 2322 | show 2323 | repeat (20) 2324 | change [pixelate v] effect by (-5) 2325 | change [ghost v] effect by (-4) 2326 | end 2327 | wait until 2328 | repeat (20) 2329 | change [pixelate v] effect by (5) 2330 | change [ghost v] effect by (4) 2331 | end 2332 | hide 2333 | 2334 | 2335 | when green flag clicked 2336 | hide 2337 | 2338 | 2339 | when I receive [blob8108 v] 2340 | reset timer 2341 | go to x:(0) y:(-360) 2342 | show 2343 | go to front 2344 | repeat until <(timer) > [.3]> 2345 | set y to ((([cos v] of ((timer) * (600))) * (-180)) - (180)) 2346 | end 2347 | set y to (0) 2348 | wait until <(timer) > [1.6]> 2349 | repeat until <(timer) > [1.9]> 2350 | set y to ((([cos v] of (((timer) - (1.6)) * (600))) * (180)) - (180)) 2351 | end 2352 | hide 2353 | 2354 | 2355 | when green flag clicked 2356 | hide 2357 | 2358 | 2359 | when I receive [blob8108 v] 2360 | show 2361 | set [ghost v] effect to (100) 2362 | go to x:(0) y:(-360) 2363 | wait (0) secs 2364 | go to front 2365 | repeat until <(timer) > [.3]> 2366 | set [y v] to ((([cos v] of ((timer) * (600))) * (-180)) - (180)) 2367 | set y to (y) 2368 | if <(y) < [-60]> 2369 | set [ghost v] effect to ((-60) - (y)) 2370 | else 2371 | set [ghost v] effect to (0) 2372 | end 2373 | go to front 2374 | end 2375 | set y to (0) 2376 | wait (0.1) secs 2377 | repeat until <(timer) > [.6]> 2378 | set x to (([sin v] of (((timer) - (0.4)) * ((90) / (0.2)))) * (15)) 2379 | end 2380 | wait (0.2) secs 2381 | repeat until <(timer) > [1.2]> 2382 | set [t v] to (((timer) - (0.8)) * ((90) / (0.4))) 2383 | set x to (((([sin v] of (t)) * ([sin v] of (t))) * (-15)) + ((([cos v] of (t)) * ([cos v] of (t))) * (15))) 2384 | end 2385 | wait (0.2) secs 2386 | repeat until <(timer) > [1.6]> 2387 | set x to (([sin v] of (((1.6) - (timer)) * ((90) / (0.2)))) * (-15)) 2388 | end 2389 | repeat until <(timer) > [1.9]> 2390 | set [y v] to ((([cos v] of (((timer) - (1.6)) * (600))) * (180)) - (180)) 2391 | set y to (y) 2392 | if <(y) < [-60]> 2393 | set [ghost v] effect to ((-60) - (y)) 2394 | else 2395 | set [ghost v] effect to (0) 2396 | end 2397 | end 2398 | hide 2399 | 2400 | 2401 | when green flag clicked 2402 | hide 2403 | 2404 | 2405 | when I receive [blob8108 v] 2406 | go to x:(0) y:(0) 2407 | set [ghost v] effect to (0) 2408 | show 2409 | wait (0) secs 2410 | go to front 2411 | go back (3) layers 2412 | wait until <(timer) > [1.9]> 2413 | repeat (10) 2414 | change [ghost v] effect by (10) 2415 | end 2416 | hide 2417 | set [_done logo v] to [1] 2418 | 2419 | 2420 | when green flag clicked 2421 | hide 2422 | go to x:(0) y:(0) 2423 | 2424 | 2425 | when [thumbnail v] clicked 2426 | hide 2427 | 2428 | 2429 | show // before uploading 2430 | go to front 2431 | broadcast [Hide Cars v] 2432 | set [_done logo v] to [0] 2433 | --------------------------------------------------------------------------------