(Redirected from S:SB4STYLE)
Shortcuts: |
---|
In order to keep the Scratch Wiki looking neat, please follow the following style guide when writing <scratchblocks> on the wiki.
Feel free to fix any articles that do not conform to this guide.
This guide is intended for wiki editors, and includes guidelines on style as well as a little extra syntax. It thus serves a different purpose to Block Plugin/Syntax, which is intended for forum users and wiki editors alike.
Style Guide
Whitespace
- Always put a line break before and after the opening and closing <scratchblocks> tags.
- No:
I like this script: <scratchblocks>when gf clicked say [Hello!]</scratchblocks> Pretty, isn't it?
- Yes:
I like this script: <scratchblocks> when gf clicked say [Hello!] </scratchblocks> Pretty, isn't it?
- However, if you're writing a script with a single block, only use one line:
- Yes:
<scratchblocks>when gf clicked</scratchblocks>
- Use indentation. Always indent by 4 spaces. (This is for consistency as much as for any other reason.)
- No:
repeat (10) if <touching [mouse-pointer v]?> move (10) steps end stamp end
- Yes:
repeat (10) if <touching [mouse-pointer v]?> move (10) steps end stamp end
- Always put whitespace around inserts and embedded blocks. This is easier to read.
- However, do not include a whitespace between inputs and a % sign. This will cause an extra whitespace to appear when rendering the block.
- No:
set size to (100) %
set size to (100) %
- Yes:
set size to (100)%
set size to (100)%
- Always put spaces around the comment symbol "
//
". - No:
stamp//Draws a picture!
- Yes:
stamp // Draws a picture!
- Always include "
end
" after a C block. - No:
repeat (10) move (10) steps stamp
- Yes:
repeat (10) move (10) steps stamp end
- Always close brackets.
- No:
if <<(x position) < [3]> and <(var) = [4
- Yes:
if <<(x position) < [3]> and <(var) = [4]>>
- Specify the block category for deprecated blocks, as they may be removed from scratchblocks in the future.
- No:
play note () for () seconds
- Yes:
play note () for () seconds:: wedo
- Make sure you use the 3.0 versions of blocks (unless it's an article specifically about a version before Scratch 3.0). This includes:
- Articles or sections based on the following should use the 2.0 version of the block:
- Obsolete Scratch versions
- Scratch Modifications based on obsolete Scratch versions
- Obsolete Blocks
- Scripts which no longer function the same in the current version of Scratch
- This also applies to High Contrast versions of blocks:
- The gray
. . .
ellipsis block represents a gap in a script. This should be used when the gap needs to be filled in with other blocks or scripts. - Do not write the word "script(s)", any other obsolete block, or a comment saying "script goes here":
- No:
forever if <> then script end end
- No:
forever if <> then // script goes in here end end
- Yes:
forever if <> then . . . end end
- No:
forever if <> then // block goes here move () steps // other block goes here end end
- Yes:
forever if <. . .:: grey> then move (. . .::grey) steps end end
- Always put spaces between the dots:
. . .
. This makes the block easier to read. - No:
<scratchblocks> forever if <...:: grey> then end end </scratchblocks>
forever if <...:: grey> then end end
- Yes:
<scratchblocks> forever if <. . .:: grey> then end end </scratchblocks>
forever if <. . .:: grey> then end end
I'm rather fond of the <sb>stamp</sb> block in Scratch 3.0.
- I'm rather fond of the
stamp
block in Scratch 3.0. - You can only use a single block in the inline tag, not a whole script.
- Use inline scratchblocks to represent variable names, e.g.
(score)
: - No:
Use the "score" variable to keep track of...
- Yes:
Use the <sb>(score)</sb> variable to keep track of...
- For block links, use inline scratchblocks instead of images:
- Yes:
[[Stamp (block)|<sb>stamp</sb>]]
stamp
- Do not use inline scratchblocks in headings.
- No:
== The <sb>username</sb> block ==
- Yes:
== The username block ==
- No:
<scratchblocks>create clone</scratchblocks>
create clone
- Yes:
<scratchblocks>create clone:: control</scratchblocks>
create clone:: control
- For coloring blocks, do not use the deprecated comment syntax, which has been removed. Use the more flexible double-colon syntax instead, which also supports reporters:
- No:
create clone // category=control
- Yes:
create clone:: control
say (ultrasonic sensor:: extension)
No | Yes |
---|---|
<scratchblocks>if<mouse down?> then</scratchblocks> |
<scratchblocks>if <mouse down?> then</scratchblocks> |
<scratchblocks><(variable)=[3]></scratchblocks> |
<scratchblocks><(variable) = [3]></scratchblocks> |
<scratchblocks>(join((5)+(1))((2)/(3)))</scratchblocks> |
<scratchblocks>(join ((5) + (1)) ((2) / (3)))</scratchblocks> |
Be Explicit
The block plugin will close brackets and c-blocks for you, in case you forget. Do not rely on this; always include properly formatted scripts in wiki articles. If Javascript is disabled then the source code will be displayed directly to the user, so the scratchblocks code in articles needs to be readable.
Deprecated Blocks
Scratch 3.0 Blocks
No | Yes (on 1.4 articles) | Yes (on 2.0 articles) | Yes (on 3.0 articles) |
---|---|---|---|
(background #) |
(background #:: looks) |
(backdrop #) |
(backdrop [number v]) |
if <> |
if <>:: control |
if <> then |
if <> then |
stop script |
stop script:: control |
stop [this script v] |
stop [this script v] |
when greenFlag clicked:: hat |
when gf clicked:: control |
when gf clicked |
when gf clicked |
Yes (on general articles) | Yes (on articles about high contrast blocks) |
---|---|
move (10) steps |
move (10) steps |
Ellipsis
Note: | When creating reporter and boolean gaps, make sure to add :: grey at the end of the block to make it render properly. |
Wiki-only features
There are some extra "hidden" features intended for use on the wiki only.
Inline Scratchblocks
You can place scratchblocks inside a sentence using the <sb>
tag, like this:
Producing:
Notes:
Coloring blocks
You can override the color of a block by typing ::
followed by a category: