Basic Choices and Branching
There are some special commands you can include in your script to make your stories interactive. We have some examples of this in the Example Script: Basic Choices.
The most basic concept is “choice” which allows the user to make a choice by tapping buttons on screen. When the user makes a choice, they will then only see the part of the script associated with that choice.
Example:
HAYES
Hi there.
choice
“Hi” {
SARAH
Hi back
HAYES
You’re friendly.
} “Go away” {
SARAH
Leave me alone Hayes.
I have to study.
Plus you smell.
}
HAYES
Alright. Talk to you later
The text in quotes will appear on the buttons for the player to tap. The dialog in-between the braces will be shown if the player makes the corresponding choice. After the choice, the two separate branches merge back together, so no matter what you choose all users will see the “Alright. Talk to you later line.”
Remembering past choices
It is useful to save the results of a choice for use later in the story. A name inside parenthesis next to a choice signifies that the chosen response should be saved as that variable. To use the variable in dialog, surround the variable name in brackets. In this example, a character asks the player’s favorite color, and reacts differently to the choice. Afterward, both branches merge together and the story continues. The character later remembers the choice and repeats it back to the player later.
TYLER
What is your favorite color?
choice (fav_color)
“Pink” {
YOU
I like pink. It is super cute.
Like bunnies!
TYLER
How predictable.
} “Green” {
YOU
I like green.
TYLER
Me too.
} “Black” {
YOU
Black.
Like the cold grip of death.
TYLER
That’s dark.
}
TYLER
I’ll keep that in mind when I am buying you gifts!
YOU
Gifts huh?
TYLER
Yeah.
I will be sure to get you something nice and [fav_color].
Branching based on past choices
Once you have set a variable you can later have the user see different parts of the story based on what the variable was set to. In the example below the user will not see any choices but instead the dialog they see will be based on what they chose as their favorite color previously in the story.
YOU
Hi Tyler. Is that present for me?
TYLER
Yup. Open it!
if (fav_color is “Pink”) {
YOU
A pair of pink bunny ears!
So soft!
Thanks! I love it.
} elif (fav_color is “Green”) {
YOU
A $20 bill?
TYLER
Yeah I didn’t know what else to get.
It’s green at least!
} else {
YOU
It’s empty.
TYLER
Black is the absence of light.
Darkness is emptiness
YOU
...
TYLER
I thought you would like the metaphor.
}
For more on branching, see Complex Branching.
Helpful Video
Comments
0 comments
Article is closed for comments.