This is a tutorial about how to use Snap! features in the [scratchblocks] extension. This tutorial assumes you have general knowledge of how the scratchblocks extension works, as well as knowledge on how to change the color of a block to a category color.
Symbols are identified by a @[symbol name]. Replace [symbol name] with the actual symbol name, like addInput, delInput, or greenFlag. Symbols get turned into their corresponding icons, like a left/right arrow or green flag.
There is a problem with symbols, since symbols use the at sign to identify themselves as symbols, but Discourse also uses the at sign, to identify something as a mention. Hopefully this will get fixed, or the symbol identifier will be replaced with another character.
Workaround by @ego-lay_atman-bay: Wrap the scratchblocks tag in an HTML <p> tag to fix the symbols
<p>[scratchblocks]
...
[/scratchblocks]</p>
Lists
Empty list
(list @addInput :: list)
[scratchblocks] (list @addInput :: list) [/scratchblocks]
Non-empty List
(list [1] [2] [4] [8] @delInput @addInput :: list)
[scratchblocks] (list [1] [2] [4] [8] @delInput @addInput :: list) [/scratchblocks]
Unfortunately, there is no official way to represent an empty list input. You can, instead, put an equals sign or a triple bar (≡) in a text input to represent them.
Workaround from from @brooc210: For empty list slots, use this character: ⌸ (Not put around square brackets)
add [thing] to ⌸ :: list
add [thing] to ⌸ :: list
Grey rings
Unfortunately, I do not know if it is possible to make empty rings. (Now that I think about it, it's not much of a bummer because why would anyone would need empty rings?)
Single block with no inputs
( { show } @addInput :: grey ring)
[scratchblocks] ( { show } @addInput:: grey ring) [/scratchblocks]
Curly braces are used to say that it is a command block
Multiple blocks with no inputs
({
repeat (10)
move (10) steps
end
stop [this script v]
} @addInput :: grey ring)
[scratchblocks] ({ repeat (10) move (10) steps stop [this script v] } @addInput :: grey ring) [/scratchblocks]
Input names
( ( (foo) + (bar) ) input names: ((foo) :: grey) ((bar) :: grey) @delInput @addInput :: grey ring)
[scratchblocks] ( ( (foo) + (bar) ) input names: ((foo) :: grey) ((bar) :: grey) @delInput @addInput :: grey ring) [/scratchblocks]
Note how the upvars are surrounded by parentheses with the "grey" color.
Run/Launch Block
Without Inputs
run ({
say [Hello]
wait (1) secs
say [World!]
} @addInput :: grey ring) @addInput :: control
[scratchblocks] run ({ say [Hello] wait (1) secs say [World!] } @addInput :: grey ring) @addInput :: control [/scratchblocks]
With Inputs
launch ( { say [] } @addInput :: grey ring) with inputs: [Hello, world!] @delInput @addInput :: control
[scratchblocks] launch ( { say [] } @addInput :: grey ring) with inputs: [Hello, world!] @delInput @addInput :: control [/scratchblocks]
Variable As Procedure and Input Lists
say (call (f) input list: (list [1] [2] [4] [8] @delInput @addInput :: list) :: control)
[scratchblocks] say (call (f) input list: (list [1] [2] [4] [8] @delInput @addInput :: list) :: control) [/scratchblocks]
Yellow Event Hats
Green Flag
when green flag clicked :: control
when green flag clicked :: control
When Block
when <(points) > [9]> :: control hat
say [You won!]
when <(points) > [9]> :: control hat say [You won!]
Block Definitions
Definition Hat
< + prime? + ((number #) :: operators) + :: operators> :: control hat
<+ prime? + ((number #) :: operators) + :: operators> :: control hat
Report Block
report (val) :: control cap
( + ((val) :: operators) + :: operators) :: control hat report (val) :: control cap