Block Plugin

*"Scratchblocks" redirects here. For the blocks used in the editor, see Blocks. For the library for building creative computing interfaces, see Scratch Blocks.*
*This article or section documents the current version of Scratch (version 3.0). For this article in Scratch 2.0, see Block Plugin (2.0).*
The **Block Plugin**, also known as **scratchblocks4**, is a plugin for the Scratch Wiki and Forums (although it only supports 2.0 blocks on the Forums) maintained by the user blob8108 that allows script images to be constructed through text that is parsed and rendered. The plugin itself can be played around with on its homepage.
For example:
<scratchblocks>
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 scripts on the Wiki!]

```

end
</scratchblocks>

## Basic Syntax

Main article: Block Plugin/Syntax
On the Scratch Wiki, block 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 close 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 the Block Plugin is as follows:

## Advanced Syntax

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

```
block {
  more blocks
} optional text
```
```
do {
  ...
} in [Sprite2 v]::control
```
do {

```
 ...

```

} in [Sprite2 v]::control

```
(stack block as reporter::stack)
```
```
decorate (show::looks stack)
```

```
:: [category or #color] [shape]
```
* motion
* looks
* sound
* pen
* variables
* list
* events
* control
* sensing
* operators
* custom
* custom-arg
* extension
* grey
* undefined

`#color`s can be any hexadecimal RGB color, for example `#ff0000` which produces a pure red.
Possible `shape`s include:
* hat
* stack
* cap
* cat
```
a cool block:: #ff00ff cap
```

```
::ring
```
```
Look,({It's in a ring!}@addInput::ring
```

Also note that unlike **<scratchblocks>** which generates Scratch 3.0 blocks, **<scratchblocks version=2.0>** will generate Scratch 2.0 styled blocks, used in the example below:
<scratchblocks version=2.0>
when gf clicked

```
   repeat (10) // comment in 2.0
       move (5) steps
   end
   say [Cool! Scratchblocks in 2.0!]
   stop [this script v]

```

</scratchblocks>

1. ↑ Spelled with an e, not an a.
2. ↑ Using 3.0 instead of 2.0 also generates 3.0 styled blocks.

## Helper Tools

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

### Scratch 3.0

The user blob8108 developed Scratch 2.0's blocks, which now also supports Scratch 3.0 blocks.He also developed a converter written in JavaScript that converts an entire project's scripts into scratchblocks. It can be found here.

### Scratch 2.0

The user jvvg developed a converter written in PHP that converts scripts in the backpack. The forum thread for this converter can be viewed here.

### Scratch 1.4

The user 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.

## See Also

* The style guide for using the Block Plugin on the Scratch Wiki

## References

1. ↑ 1.0 1.1 http://scratchblocks.github.io/#?style=scratch3&script=

de:Scratch-Wiki:Hilfe:Block Plugin
fr:Blocs du forum
ja:ブロックプラグイン
ru:Scratchblocks