Worked examples
The locked door
A yes/no flag, a hidden choice and a fork, in five scenes you can play.
On this page
This story is five nodes long. It uses one yes/no value, one hidden choice and one fork. Play it first, then read how it is built.
Try it#
The hallway
- has_keyno
The map#
How it is built#
1. One value#
In Things this story remembers, add a value called has_key. Its type is Yes / no and it starts as No. Nothing else in the story needs remembering.
2. The hallway#
The hallway has three choices.
- "Take the key from the shelf" leads back to the hallway itself. It has two things attached: the check "has_key is no", and the effect "has_key, set to yes". So the choice can only be picked once, because after that the check fails and the choice disappears.
- "Try the heavy door" leads to the fork.
- "Walk away" leads to the neutral ending.
The hallway text also has a paragraph, "The key is in your pocket now", that only shows once you have the key. That uses the Shown-only-if paragraph button in the text toolbar, covered in Showing values in the text.
3. The fork#
The fork is titled "Has the key?" so you can find it in the list. It has one rule, "If has_key is yes → send to Open", and an Otherwise that sends to "The door".
"The door" is a normal scene with a single choice that leads back to the hallway.
4. The endings#
There are two: a good ending, "Open", and a neutral one, "Left alone".
Why a fork here#
You could have made two choices in the hallway, "Open the door with the key" and "Try the door", and hidden one with a check. That works, but the reader is then choosing between two ways to do the same thing, and the story has told them in advance which one will succeed.
With a fork, the reader makes one choice, "Try the heavy door", and the story decides what happens. Where the door leads depends on what they did earlier, and they did not have to be told.
Things to try#
- Add a second item, such as a lantern, and require both to open the door. Add a second check to the fork's rule.
- Make "Walk away" only appear once the reader has tried the door at least once. You will need a second value.
- Give the neutral ending a different line if the reader was carrying the key when they left.
Make your own copy#
Want to take it apart? Copy this story into your Studio and change it however you like.