< Block Plugin (1.4)

This article shows the Block Plugin syntax.

On the Scratch Wiki, code must be inserted between the <scratchblocks version="2.0">...</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
when gf clicked :: control
forever
   turn cw (15) degrees
   say [Hello!] for (2) secs
   if <mouse down?> :: control
      change [mouse clicks v] by (1)
   end
end

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).

move (10) steps
move (10) steps

String Insert

String inserts are created with the token [lorem ipsum]

say [Hi]
say [Hi]
think [bye]
think [bye]

Block Insert

Boolean blocks and Reporter blocks are created with <boolean> and (reporter), respectively.

if <<mouse down?> and <(costume #) = [1]>>
stamp
end
if <<mouse down?> and <(costume #) = [1]>> :: control
stamp
end

Note that booleans appear like reporter blocks due to a technical limitation.

Color Picker

A color picker is represented with [#hexcode]. #hexcode is a hexadecimal color code.

set pen color to [#00FF00]
set pen color to [#00FF00]


Dropdown List

Dropdown lists are created with the code [selection v]

broadcast [start v]
broadcast [start v]

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
when gf clicked :: control
stamp


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
when [Sprite1] clicked :: control hat
stamp

The When () key pressed block uses a drop-down menu:

when [space v] key pressed
stamp
when [space v] key pressed
stamp

Stack Blocks

The Turn () Degrees (clockwise) block can be written two ways:

turn cw () degrees
turn right () degrees
turn cw () degrees

The Turn () Degrees (counter-clockwise) block can be written two ways:

turn ccw () degrees
turn left () degrees
turn ccw () degrees

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:

repeat (10)
move (5) steps
stamp
end
repeat (10)
move (10) steps
stamp

Comments

Comments are created with the //comment token, after a block.

move (10) steps //is that too far?
move (10) steps //is that too far?

Comments are grey on the Scratch Wiki, and light yellow on the forums.

Be Careful making () is less than ().png and () is greater than ().png

Due to the syntax, you must add spaces to both sides of the middle character in the () is less than ().png and () is greater than ().png blocks.

If you forget the spaces, you'll get:

<[]<[]> <[]>[]>

<[]>
<[]>[]::obsolete>

To correct the problem, insert spaces:

<[] < []> <[] > []>

<[] < []>
<[] > []>

Compile Block Plugin Code

To efficiently generate block plugin code for large scripts, one can use project summaries. After writing the script in Scratch, shift-click the file menu and select "write project summary". Pick a directory. Once the .txt file is generated, it will contain the script in block plugin format, with a few minor differences that can be adjusted.

An alternative is to use LS97's Scratch plugin that correctly exports a script to ScratchBlocks format.

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