Using Variables
Variables allow you to store data that can change based on the player's actions and influence the storyline's progression. Last time, we saved our protagonist's choice and introduced a health variable. Now, let's talk about how to use variables in your story.
Let's assume that at the end of our escape, everything went well, and it's time to start the first mission. Create a new chapter by clicking + in the sidebar:
title: mission
checkpoint_name: "First Mission"
---
===
At the end of the escape chapters, add <<jump mission>> to link them to the new node.
Callbacksβ
Callbacks are a way to show the player that their actions are influencing the story, even if it's not entirely true. Let's add some callbacks.
For example, we can mention the path that was chosen at the beginning of the story. Add the following to the mission chapter:
title: mission
checkpoint_name: "First Mission"
---
<<if $escape_choice == "ventilation">>
Thanks, escaping through the ventilation was a good move.
<<elseif $escape_choice == "scaffolding">>
Next time, avoid climbing down the scaffolding. That was close.
<<endif>>
===
Type \\if in the editor to quickly insert an <<if>> / <<endif>> block. The cursor is placed right at the condition β just start typing.
Here, we use the <<if>> structure to check the value of the $escape_choice variable and show different messages based on the result. This doesn't affect the plot, but it helps the player feel more engaged.
Response Optionsβ
...
So, should we start preparing for the next mission?
-> Send me the operation plan
-> First, go to the medbay to recover <<if $health < 100>>
Ok, I'll be back soon.
<<set $health = 100>>
<<wait 10>>
All set, I'll send you the operation details now.
In this example, we added a response option that depends on the value of the $health variable. If the agent's health is below 100, we can send them to the medbay to recover. The player won't see this option if the agent's health is already full.
Use the debugger's Variables panel to change $health to different values and test both branches without replaying from the start.
These are simple examples of how to work with variables. You can fine-tune the storyline by adding more variables and conditions. For instance, you could add a $money variable and offer different actions based on its value, or introduce a $weapon variable that alters the story depending on the agent's equipment. The possibilities are endless.