How to Make a Simple Script in Scratch on the Raspberry Pi - dummies

How to Make a Simple Script in Scratch on the Raspberry Pi

By Richard Wentk

You can use Scratch on your Raspberry Pi to make a game or tell a story by dragging the blocks into a list with your mouse. The blocks clip together on the screen, a bit like real plastic blocks.

Lists are called scripts. When you click on a script, Scratch goes through the blocks one by one, and each block does something to the sprites it controls.

You can make a simple script by dragging blocks to the Scripts area in the middle of the screen:

  1. Drag a move block to the Scripts area.

  2. Drag a turn block to the Scripts area and hold it just under the move block without lifting your finger from the mouse button.

    Scratch shows a wide white line, like the one in the following figure.


  3. Let go of the mouse.

    When you let go of the mouse button, the bottom block clips to the top block.

    You made a script!

When you click anywhere on the script, Scratch steps through each block in turn. This script makes the sprite move, and then it makes it turn.

This script has only two blocks, but if you made a script with hundreds of blocks, Scratch would start at the top block, do what it says, move to the next block, do what it says, and so on, all the way down the list, in order.

Making a script work is called running a script. Imagine a script wizard running from the top of the script to the bottom and making each block work in turn. Scripts work a lot like that, only you can’t see the wizard because he’s hiding behind the stage.

You can clip blocks to the top of a script as well as the bottom. You can clip a block whenever it has a slot or a tag.

Scratch has some cool extra tools. To see them, right-click on a block or a script.

  • help: Click help to get a hint about what a block does. The hint appears in a window. Click OK to make the window go away.

  • duplicate: Click duplicate to make a copy of a script or block. The copy appears in the Scripts area.

  • delete: Click delete to get rid of a script or block from the script area. The block or script disappears. If you do this by accident and change your mind, choose Edit→Undelete from the menu at the top of the Scratch window to make the script/block reappear.