Without trying this in Snap!, try to answer the following question:
What does the following set of scripts do when the Turn1
message is broadcast?
Choose one:
broadcast Turn1 and wait
block after the say Team! ...
block will execute. Snap! will blindly follow its script.
Right! Here, we see an infinite loop, or a never-ending loop. Whenever this happens in Snap!, we can always stop it by pressing the Stop button at the top right of the window, just above the stage.
Why does this happen? Well, when you the Turn1
message is first broadcast,
the sprite says Go!
for half a second, and then broadcasts a Turn2
message.
If there is any character that has a script that responds to the Turn2
message, it will perform that script.
In this case, the same sprite has a script that responds to the Turn2
message, and so it will run the corresponding script. It says Team!
and then broadcasts a Turn1
message. But, it also has a script that responds to the Turn1
message, which in turn sends a Turn2
message, and so on. This continues until the scripts are forced to stop.
Turn1
script.