Operation Manual

A beginner’s guide to Scratch
33
Notes:
Finally, complete your script with a “wait [ ] secs” block and “stop all” block from
Control. Set the value of the “wait [ ] secs” to “4” and place both blocks at the very
end of your script, outside both “if/else” blocks.
The script for the stage
To complete the program we need to program the backgrounds. If you haven’t
imported them from RPiScratch\Resources\Backgrounds, now’s the time to do it.
A
The cat has
chosen A.
So A is stored
in the variable
“country”.
The destination the dog chooses will be stored in the variable “country”. This is important,
because this variable will be used by the script for the stage to determine the script’s output.
Select the stage in the Sprites List and build the script you can see in the
screenshot above.
Here, we have created three “nested if” conditional statements, which will switch
the background according to the dog’s choice. We use the term “nested” when
one conditional statement is put inside another one.
Each time we use this program, the stage has to be reset to the “brick-wall1
background. The conditional statements need to keep checking until the dog has
made her choice, so I have put them in a “forever loop”.
Tip...
Users do not
always do
what they are
supposed to do.
If a user provides
an unexpected
input, this can
cause an “error”
in the program,
which will often
cause the
program to
“crash”. Programs
that have errors in
them are said to
contain “bugs”.
An important task
for a programmer
is testing their
program to make
sure it is bug-free.
A
country
country