O'Reilly logo

Raspberry Pi For Dummies by Mike Cook, Sean McManus

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Scripts

Clicking blocks in the Blocks Palette is one way to issue commands to Scratch, but you’re not really programming. If you have to click each block every time you want to run it, you’re doing all the hard work of remembering the instructions and the computer can only work as fast as you can click the blocks.

A program is a reusable set of instructions that can be carried out (or run) whenever you want. To start to create a program, you drag blocks from the Blocks Palette and drop them in the Scripts Area in the middle of the screen. Most blocks mentioned so far have a notch on the top of them and a lug on the bottom of them, so they fit together like jigsaw pieces. You don’t have to align them perfectly: Scratch snaps them together for you if they’re close enough when you release the mouse button.

You put your blocks in the order you want Scratch to run them, starting at the top and working your way down. It’s a bit like making a to-do list for the computer.

A group of blocks in the Scripts Area is called a script, and you can run it by clicking anywhere on it. Its border flashes white, and you’ll see the cat move around the Stage as you’ve instructed it to.

You can have multiple different scripts in the Scripts Area, so you could have one to make the cat walk left and another to make it walk right, for example. When you add multiple sprites (see Chapter 11), each sprite has its own Scripts Area and scripts there to control it.

If you want to tidy up the Scripts ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required