Archive.png This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.
SandCastleIcon.png This article has links to websites or programs outside of Scratch and Wikipedia. Remember to stay safe while using the internet, as we cannot guarantee the safety of other websites.
This article or section documents an outdated version of Scratch (version 2.0). For this article in the current version (version 3.0), see Block Plugin (3.0).

The Block Plugin, also known as scratchblocks, was a plugin for the Scratch Wiki and Discussion Forums created by blob8108 that allows script images to be constructed through text that is parsed and rendered. The plugin can be played around with here. There was also a discontinued forum topic here.

It is a complete rewrite of the old plugin by JSO that was used on the old Scratch forums. On the Scratch Wiki, it was replaced by a new version also by blob8108 after the release of Scratch 3.0, but the Discussion Forums still use the 2.0 version.

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. On the Scratch Wiki, uniquely, a single block can also be inserted inline between <sb>...</sb> tags to avoid breaking lines.

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 Result
block name
a block
stamp
stamp
end
stops a C block (only necessary if more blocks come after the C block)
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!]
(var)
a variable or reporter block
(x position)
(x position)
(12.34)
a number input
wait (0.5) secs
wait (0.5) secs
[item v]
a dropdown input
broadcast [You Win v]
broadcast [You Win v]
<bool>
a boolean block
<mouse down?>
<mouse down?>
[#ABCDEF]
a color input
<touching color [#0000FF]?>
<touching color [#0000FF]?>
define
a custom block hat
define jump (height)
define jump (height)
// comment
a comment
show // now you see me
show // now you see me
...
a placeholder block denoting an arbitrary script
if <(var) = [this]> then
  ...
end
if <(var) = [this]> then
  ...
end

Advanced Syntax

The following is some more in-depth syntax of scratchblocks2.

Code Use Example Result
block {
  more blocks
} optional text
Custom C blocks
do {
  ...
} in [Sprite2 v]::control
do {
  ...
} in [Sprite2 v]::control
(stack block as reporter::stack)
Cause a block to have a stack block as an input.
decorate (show::looks stack)
decorate (show::looks stack)
:: [category or #color] [shape]
Force a block to look a certain way. Possible category options include:
  • motion
  • looks
  • sound
  • pen
  • variables
  • list
  • events
  • control
  • sensing
  • operators
  • custom
  • custom-arg
  • extension
  • grey[note 1]
  • undefined

#colors can be any hexadecimal RGB color, for example #ff0000 which produces a pure red.

Possible shapes include:

  • hat
  • stack
  • cap
a cool block:: #ff00ff cap
a cool block:: #ff00ff cap
::ring
Replicate Snap's "ringify" feature. This can be used in conjunction with the above colon syntax as well.
Look,({It's in a ring!}@addInput::ring
Look,({It's in a ring!}@addInput::ring
  1. Spelled with an e, not an a.

Helper Tools

Here are some tools that will convert real blocks in Scratch projects into scratchblocks code.

Scratch 1.4

  • The Scratcher LS97 developed a plugin for the Scratch program itself that converts a script into scratchblocks (the original) code. The forum thread for the plugin can be viewed here.

Scratch 2.0

  • blob8108 developed a converter written in JavaScript that converts an entire project's scripts into scratchblocks. See it in action here.
  • jvvg developed a converter written in PHP that converts scripts in the backpack. The forum thread for this converter can be viewed here.

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.