The First Node
To start writing your story, follow these steps:
- Go to the Story folder in your project.
- Create a file named escape.yarn.
The file name can be anything as long as it has the .yarn
extension, but we recommend using a name that reflects the content of the story.
- In this file, create your first node named escape.
title: escape
---
===
This is our starting node. Let’s allow the player to return here and add the checkpoint_name parameter. This way, the player's progress will be saved at this node.
title: escape
checkpoint_name: "Escape"
---
===
Starting Point
By default, you already have one node that serves as the entry point. It is located in the start.yarn file. You can change this by removing the is_entry_point
parameter from the start node and adding it to the escape node. However, we do not recommend doing this.
In the start node, it's convenient to declare variables that will be used throughout the story. But we need to link the escape node to the starting point so the player can begin the story from this node. To do this, we’ll add the command <<jump escape>>
at the end of the start node.
title: Start
is_entry_point: true
---
// Game vars
// Jump to your start node
<<jump escape>>
===
Writing the Story
Let's return to the escape node and write the first dialogue. In this node, the agent reports that they've been exposed, and the player will need to make a choice to help them escape.
title: escape
checkpoint_name: "Escape"
---
Urgent! I've been exposed. I need to get out of here fast.
-> What happened?
-> How can I help?
No time to explain, just help me get out of here!
-> Where are you now?
I'm in Lab #15, but they've already found me. I need an escape plan.
===
As you can see, we give the player a choice of responses, but these replies don't affect the progression of the story. This is to allow the player to feel part of the story.
However, we can't do this for too long, as the player will get bored. Let's add a real choice that will impact the storyline.
Break up messages with blank lines to make the text more readable.
...
I'm in Lab #15, but they've already found me. I need an escape plan.
-> Use the ventilation
<<jump escape_ventilation>>
-> There are scaffolding outside the window; you can climb down them
<<jump escape_scaffolding>>
===
First Choice
As you can see, we added two options, each directing the player to a different node. Since we are within the same narrative block, we'll describe these nodes right here, just after the escape node (after the ===
symbol).
...
I'm in Lab #15, but they've already found me. I need an escape plan.
-> Use the ventilation
<<jump escape_ventilation>>
-> There are scaffolding outside the window; you can climb down them
<<jump escape_scaffolding>>
===
title: escape_ventilation
---
===
title: escape_scaffolding
---
===
Let’s remember the player’s choice for future reference.
We will declare the variable escape_choice
in the start node.
title: Start
is_entry_point: true
---
// Game vars
<<declare $escape_choice = ''>>
// Jump to your start node
<<jump escape>>
===
Now we will modify the escape_choice value based on the player's selection.
...
I'm in Lab #15, but they've already found me. I need an escape plan.
-> Use the ventilation
<<jump escape_ventilation>>
-> There are scaffolding outside the window; you can climb down them
<<jump escape_scaffolding>>
===
title: escape_ventilation
---
<<set $escape_choice = 'ventilation'>>
===
title: escape_scaffolding
---
<<set $escape_choice = 'scaffolding'>>
===
The story can get more and more complex. For instance, let’s say the agent gets injured on the scaffolding, and we want to decrease their health. To do this, we'll add a health variable in the start node and decrease it in the escape_scaffolding node.
start.yarn
title: Start
is_entry_point: true
---
// Game vars
<<declare $escape_choice = ''>>
<<declare $health = 100>>
// Jump to your start node
<<jump escape>>
===
escape.yarn node escape_scaffolding
...
Alright, I’m climbing down the scaffolding.
<<wait 5>>
<<set $health = $health - 10>>
I've been shot! Damn, that was close. I need to move faster.
-> Go back to the lab, we'll try the ventilation
<<jump escape_ventilation>>
-> Keep climbing down
...
===
As you can see, we added the command <<set $health = $health - 10>>
, which reduces the health variable by 10. This allows us to create complex storylines where the player's actions affect the outcome.
Additionally, we added the <<wait 5>>
command, which adds a delay before the next message. It simulates the time needed to climb down and can be used to build tension.
You can also create loops if the player decides to return to the lab by adding <<jump escape_ventilation>>
. This approach allows you to build intricate storylines where the player can go back to previous choices and change the course of the story.