Snap [scratchblocks] Tutorial

This is a tutorial about how to use Snap! features in the [scratchblocks] extension.

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.

Solution 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. Like so:

[scratchblocks]
add [thing] to [≡]
[/scratchblocks]

Grey rings

Unfortunately, I do not know if it is possible to make empty rings.

Single block with no inputs

( { show } @addInput :: grey ring)

[scratchblocks] ({ show } @addInput:: grey ring) [/scratchblocks]
Curly braces are used to specify a block as 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]

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

[scratchblocks]
when green flag clicked :: control
[/scratchblocks]

When Block

when <(points) > [9]> :: control hat
say [You won!]

[scratchblocks]
when <(points) > [9]> :: control hat
say [You won!]
[/scratchblocks]

Block Definitions

Definition Hat

< + prime? + ((number #) :: operators) + :: operators> :: control hat

[scratchblocks]
<+ prime? + ((number #) :: operators) + :: operators> :: control hat
[/scratchblocks]

Report Block

report (val) :: control cap

[scratchblocks]
( + ((val) :: operators) + :: operators) :: control hat
report (val) :: control cap
[/scratchblocks]

Why do your things have [scratchblocks](list )[/scratchblocks] at the end of them?

Otherwise, cool tutorial.

i said it at the beginning:

also that's a bit rude

Oh, I understand now.

Sorry, I didn't mean it that way. It wasn't wasted as I learnt something. I have removed it.

to not get

[scratchblocks]
(list @addInput :: list)
[/scratchblocks]

put ` around the scratchblocks tags, like

`
[scratchblocks]
(list @addInput :: list)
[/scratchblocks]
`

[scratchblocks] (list @addInput :: list) [/scratchblocks]

to get `, just click on the </> button when making a post, and just remove the extra things.

thanks, i added that in (except there's something wrong that solution...)

ok, I found a working solution, just wrap the scratchblocks with <p>...</p>

like

<p>
[scratchblocks]
green flag @greenFlag
this is block 2 :: #206549
[/scratchblocks]
</p>

[scratchblocks] green flag @greenFlag this is block 2 :: #206549 [/scratchblocks]

This is great, thanks guys!

thanks again

I think that this thread should be a sticky. It is really useful.

[scratchblocks] well...the p tag works, custom colors without using preformatted text ::#256 [/scratchblocks]

what is that?

[scratchblocks] Upvars look more like: :: block pen ( ( (foo) + (bar) ) input names: ((foo) :: variables) ((bar) :: variables) @delInput @addInput :: grey ring) [/scratchblocks]

This was seen before. Ask my cousin. Well, ya cant. It happens when u select rhe trxt of the scratch blocks and some outside of it.(do not end the scratch blocks. Get partial and partial.

it's

[scratchblocks] (((foo) + (bar)) input names: ((foo) :: grey) ((bar) :: grey) @delInput @addInput :: grey ring [/scratchblocks]

and here's an image from snap to show that I'm right
prototype script pic

Oh. I havent checked that. I mustve bennnusing rhat with custom variable blocks.
O well...

I just got really confused when I saw the quote...that I said?
0-0

How do i make a js function reporter scratchblock?
Or how to make "(", ")", "<", ">", "[", "]", "{" and "}" act as text

[scratchblocks] (JavaScript function \( [] @delInput @addInput \) \{ [] \} :: operators) [/scratchblocks]

(JavaScript function \( [] @delInput @addInput \) \{ [] \} :: operators)

use backslashes before the character to write them as text

how do I make scratchblocks with a multiline input?