Teste dos blocos do Scratch
This article shows the Block Plugin syntax.
On the Scratch Wiki, code must be inserted between the <scratchblocks>...</scratchblocks> tags, while on the forums they are inserted between [scratchblocks]...[/scratchblocks] tags.
Every block goes on a new line, and is written as the text on the block is shown on Scratch. For example:
Code | Result |
---|---|
when gf clicked forever turn cw (15) degrees say [Hello!] for (2) secs if <mouse down?> change [mouse clicks v] by (1) end end |
<scratchblocks> when gf clicked forever turn cw (15) degrees say [Hello!] for (2) secs if <mouse down?> change [mouse clicks v] by (1) end end </scratchblocks> |
Arguments
Arguments, or inputs to a blocks, are represented within the block with various codes.
Numerical Insert
The round numerical insert is used with the token (10)</syntaxhighlight>.
move (10) steps
<scratchblocks>move (10) steps</scratchblocks>
String Insert
String inserts are created with the token [lorem ipsum]</syntaxhighlight>
say [Hi]
<scratchblocks>say [Hi]</scratchblocks>
Block Insert
Boolean blocks and Reporter blocks are created with <boolean></syntaxhighlight> and (reporter)</syntaxhighlight>, respectively.
if <<mouse down?> and <(costume #) = [1]>>
stamp
end
<scratchblocks>
if <<mouse down?> and <(costume #) = [1]>>
stamp
end
</scratchblocks>
Note that booleans appear like reporter blocks due to a technical limitation.
Color Picker
A color picker is represented with [#hexcode]</syntaxhighlight>. #hexcode is a hexadecimal color code.
set pen color to [#00FF00]
<scratchblocks>set pen color to [#00FF00]</scratchblocks>
This website can be used to find hexadecimal colors.
Dropdown List
Dropdown lists are created with the code [selection v]</syntaxhighlight>
broadcast [start v]
<scratchblocks>broadcast [start v]</scratchblocks>
Special Blocks
Some blocks have different code based on their unique shapes and features, as well as technical limitations.
Hat Blocks
The When Green Flag Clicked block can be typed with any of the following syntax:
when green flag clicked
when gf clicked
when flag clicked
<scratchblocks>
when gf clicked
stamp
</scratchblocks>
The When () Clicked block requires the sprite's name to be surrounded by brackets. The sprite's name will appear like a text box due to technical limitations.
When [Sprite1] Clicked
<scratchblocks>
When [Sprite1] Clicked
stamp
</scratchblocks>
The When () key pressed block uses a drop-down menu:
When [space v] key pressed
stamp
<scratchblocks>
When [space v] key pressed
stamp
</scratchblocks>
Stack Blocks
The Turn () Degrees (clockwise) block can be written two ways:
turn cw () degrees
turn right () degrees
<scratchblocks>
turn cw () degrees
</scratchblocks>
The Turn () Degrees (counter-clockwise) block can be written two ways:
turn ccw () degrees
turn left () degrees
<scratchblocks>
turn ccw () degrees
</scratchblocks>
C Blocks
C blocks must be closed by typing "end" after the last stack block inside it. However, C blocks at the end of a script will close automatically. For example:
repeat (10)
move (5) steps
stamp
end
repeat (10)
move (10) steps
stamp
Makes:
<scratchblocks>
repeat (10)
move (5) steps
stamp
end
repeat (10)
move (10) steps
stamp</scratchblocks>
Comments
Comments are created with the //comment</syntaxhighlight> token, after a block.
move (10) steps //is that too far?
<scratchblocks>move (10) steps //is that too far?</scratchblocks>
Comments are grey on the Scratch Wiki, and light yellow on the forums.