Time for action – counting our fortunes with mod
Now, we will refine how the teller determines what fortune to give by counting the questions and issuing a negative response for every fifth question. If you copied the list of Magic 8-Ball responses, as I did, then your negative responses are items 15 through 20 in the answers list. If you added your own answers to the list, move the negative responses to the end of the list. You can do this in a text editor and reimport the answers list. The steps are as follows:
- Our first task is to set up a variable to count how many questions the seeker asks so that we can calculate whether or not it's time to answer in negatives. Select the teller from the sprites list and create a new variable named
question number
and make it For this sprite only. - Add the when flag clicked block to the scripts area.
- From the Variables palette, add the set question number to (0) block to the when flag clicked block. Now, we have a way to reset our counter...