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 – validating the seeker's question


Now that we're prompting the player for a question via the seeker and adding it to the questions list, it is a good idea to check for some common errors that may come our way. First, we're going to make sure the seeker types something into the textbox when prompted. Secondly, we're going to check for the duplicate questions because receiving different answers for the same question may expose the teller's randomness.

Select the Scripts tab of the teller sprite and let's begin:

  1. In the when I receive (intro) stack, add a repeat () until block right before the broadcast (fortune) block.

  2. As we have two conditions to check, insert the () and () block from the Operators palette to the value in the repeat () until block.

  3. In the first value of the and block, add a greater than (>) block.

  4. To the first value of the greater than block, add the length of () block from the Operators palette. Then, add the answer block as the length value.

  5. In the second value...