Multiple Choice Where What Happens Depends on the Answer🔗

When you want to make the entirety of what happens to the user depend on their answers to questions, you use multiple indentation, creating a "choose-your-own-adventure" style of experience. Take a look at the following example:

*question: Which of these animals is least awesome?
	Goat
		So, you're hating on goats
		*question: What have goats ever done to you?
	Fish
		Fish disfavorer! Get out of my face.
		*quit

Now for something completely different.

â–¶ Run

In this case, the answer the user selects to the question "Which of these animals is least awesome?" will determine what happens next. If the user selects the answer "Goat" to the multiple choice question presented to them, they'll next see the text "So, you're hating on goats" and then they'll be asked the question "What have goats ever done to you?" Once the user answers, there are no more lines indented beneath "Goat", so the program continues past the end of the question. That means that the user will then have "Now for something completely different." displayed to them.

If instead of selecting "Goat" the user selected "Fish," they would see the text "Fish disfavorer! Get out of my face." and then the program would immediately (with no delay) stop running due to *quit being reached. The phrase "Now for something completely different." would not be displayed to the user, due to the *quit keyword causing the program to exit this GT run immediately.

Indentation can go as "deep" as you like. For instance, take a look at this example, in which what happens is totally determined by the answers given to the questions at each indentation level:

*question: Pick a number
	1
		*question: Pick a letter
			a
				*question:Pick an animal
					Dog
					Cat
			b
				*question: Pick an animal
					Bat
					Rat
	2
		That's enough for today!

â–¶ Run

The program will begin by saying to the user "Pick a number" and presenting two options for them to choose from ("1" and "2"). If the user selects "1," then the lines of GT that are indented beneath the "1" answer run next. If instead the user had selected "2," what would happen next would be determined by the line indented beneath the "2" answer. In the case of selecting "1," the user would receive another question ("Pick a letter") and then present the user with the two options, "A" and "B". If they then choose "A," the response "Pick an animal" will follow, with the options "Dog" and "Cat". If instead the user were to choose "B" at this stage rather than "A", they would again get the response "Pick an animal," but this time with the options "Bat" and "Rat".

We see that by using indentation, we can dictate what the user experiences depending on how they answer questions.


Next: