Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By : Michael Badger
Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By: Michael Badger

Overview of this book

Table of Contents (18 chapters)
Scratch 2.0 Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – selecting a random fortune


We're going to use a separate stack of blocks to handle the script to issue a fortune. The steps are as follows:

  1. With the teller sprite selected, add a when I receive (fortune) block to the scripts area. Attach a say () for () secs block.

  2. From the Data palette, drag the item () of () block into the first value of the say block. Select random for the position value and answers from the available lists.

  3. Test the program by clicking on the seeker sprite. If all goes well, you will receive an answer (that is, a fortune) in response to your question. If your seeker repeats the question, you can remove the say block we used as a debug step in the previous exercise. The following screenshot shows our sample script so far.

What just happened?

We'll pause here for a brief moment, so you can reflect on your future life as a physic in the carnival. Our game framework is complete in that we have everything we need to ask a question and receive a fortune.

In this...