From Test-Scratch-Wiki
(Redirected from Eng:Block Plugin (2.0))
- This article or section documents an outdated version of Scratch (version 2.0). For this article in Scratch 1.4, see Eng:Block Plugin (1.4).
This page has links to outside of the Scratch website or Wikipedia. Remember to stay safe when using the internet as we can't guarantee the safety of other sites. |
The Block Plugin, also known as scratchblocks2, is a plugin for the Scratch Wiki and Scratch forums created by blob8108 that allows script images to be constructed through text that is parsed and rendered. You can try playing around with the plugin on this or this testing page.
It is a complete rewrite of the old plugin by JSO that was used on the old Scratch forums.
Example:
define dance (speed) set [dist v] to ((speed) * (distance to [mouse-pointer v])) repeat until <(timer) > [10]> move (dist) steps next costume play note (pick random (40) to (100)) for (0.5) beats say [Wow! Scratch 2.0 scripts on the Wiki!] end
Basic Syntax
- Main article: 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.
The block plugin tries to match the code you write as closely as possible, and does not check you've used the correct syntax. The block text is only used to find the correct color.
The basic syntax of for the Block Plugin is as follows:
Code | Use | Example | Which renders |
---|---|---|---|
block name
|
a block | stamp
|
stamp |
end
|
stops a C block (only necessary in the middle of a script) | repeat (5) move (10) steps end say [Done!] |
repeat (5) move (10) steps end say [Done!] |
[text]
|
a text input | say [Hello World]
|
say [Hello World] |
(variable)
|
a variable or Reporter Block | (x position)
|
(x position) |
(123.4)
|
a number input | wait (0.5) secs
|
wait (0.5) secs |
[text v]
|
a dropdown box | broadcast [Start v]
|
broadcast [Start v] |
<boolean>
|
a Boolean Block | <mouse down?>
|
<mouse down?> |
[#FFFFFF]
|
a color input | <touching color [#FF0000]?>
|
<touching color [#FF0000]?> |
define
|
a Custom Block hat | define jump (height)
|
define jump (height) |
// text
|
a comment | show // Appear!
|
show // Appear! |
. . .
|
a placeholder for unspecified, optional scripts | repeat until <touching [sprite 1 v]?>
|
repeat until <touching [sprite 1 v]?> . . . |
:: shape/category
|
forces a block to appear as a specific category, or as a specific shape. | custom block :: looks stack
|
custom block :: looks stack |
Advanced Syntax
More in-depth documentation of the scratchblocks2 plugin is listed here:
Markup | Usage | Possible syntax |
---|---|---|
{stack}
|
Code placed inside curly brackets is encapsulated in its own stack block. | Modifiers must be included inside the brackets in order to remain valid. |
(reporter)
|
Code placed inside parenthesis is encapsulated in its own reporter block. | Modifiers must be included inside the parenthesis in order to remain valid. |
<boolean>
|
Code placed inside inequality symbols is encapsulated in its own boolean block. | Modifiers must be included inside the inequality symbols in order to remain valid. |
::(color)
|
Forces target block to inherit color of the keyword's respective category. Input a RGB value starting with a # to use any color; Ex. #2AE6AE | Colons are placed at the end of any block. Possible inputs that can be placed after the two colons:
|
::(type)
|
Forces target block to inherit shape of the keyword's respective category. | Colons are placed at the end of any block. Possible inputs that can be placed after the two colons:
|
::ring
|
Replicates Snap's "ringify" feature. | This modifier can be appended to the end of a block to "ringify" its target block. It can be used in conjunction with other "colon modifiers." |
//(comment)
|
Used to replicate comments in the Scratch editor. The double slashes are a common annotation feature found in many text based languages. | The comment must be placed at the very end of the line because all characters after the double slashes will be interpreted as a comment. |
[text v] (number v)
|
Used to turn text and number inputs into drop-down menus. | The space and letter "v" must be inserted immediately before the closing bracket/parenthesis of the text/number input. |
Helper Tools
There are a few tools that you can use that will take blocks directly from a Scratch project, and turn them into text that you can paste inside a <scratchblocks>
tag.
For Scratch 1.4
- The Scratcher LS97 developed a plugin for the Scratch program that converts a script to ScratchBlocks code. The forum thread for this plugin is here.
For Scratch 2.0
- blob8108 developed a JavaScript converter for Scratch 2.0 that will convert an entire project, and the code for that is here.
- jvvg developed a PHP version that will convert scripts in users' backpacks, and the forum thread is here.
See Also
- S:SB2STYLE, the style guide for the Block Plugin