Revision as of 12:51, 23 February 2015 by Blob8108 (talk | contribs) (For Scratch 2.0: generator has moved also)

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 the test 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
  play note (42 v) 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 doesn't check you've used the correct syntax. The block text is only used to find the correct colour.

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 // category=looks

Note Note: The block plugin makes booleans look like reporter blocks.

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.

History

This article or section documents an outdated version of Scratch (version 2.0). For this article in Scratch 1.4, see Block Plugin (1.4).