Jumps
You might have noticed that it’s a bit hard for you, the writer, to follow what’s going on, when you start nesting too many options, have lots and lots of lines of dialogue, or a combination thereof. When things start to become too much for a single node, you can break things into multiple nodes and use the Yarn Script <<jump>>statement to, you guessed it… jump to another node.
Jumping between nodes
Using Try Yarn Spinner, update the Yarn Script to look like the following example of the <<jump>> statement in action.
title: Start
---
Narrator: Hi, I'm the narrator for this beginner's guide!
Narrator: I'm talking to you with Yarn Spinner!
Narrator: What do you think of all this, then?
-> It's alright, I guess.
<<jump Alright>>
-> It's great. I love it.
<<jump Love>>
===
title: Alright
---
Narrator: Well, that's not very nice.
Narrator: I'm trying my best here.
-> Are you really? I don't think so.
Narrator: Well, I never!
Narrator: I'm going to have to have a word with the writer.
-> Oh, OK. I'm sorry.
Narrator: That's better.
Narrator: I'm glad we could resolve this.
===
title: Love
---
Narrator: Oh, you're too kind.
Narrator: I'm just doing my job.
-> You're doing a great job.
Narrator: Oh, stop it, you.
Narrator: You're making me blush.
-> You're a natural.
Narrator: Oh, you.
Narrator: I'm but a humble narrator.
===
In Try Yarn Spinner, click on Run to play it, and observe how the jumps work.
By now, hopefully, you’re seeing what’s going on here, but let’s go through it to make sure.
In this yarn script there are three nodes: Start, Alright, and Love and, depending on the choice made by the player inside the Start node, the conversation will jump to Alright (if they’re a bit rude) or Love (if they’re somewhat polite).
The jump statement is used to move the narrative to a different node, and takes a single parameter, which is the full title of the node you want to jump to, and you can see it in use in our Start node:
title: Start
---
Narrator: Hi, I'm the narrator for this beginner's guide!
Narrator: I'm talking to you with Yarn Spinner!
Narrator: What do you think of all this, then?
-> It's alright, I guess.
<<jump Alright>>
-> It's great. I love it.
<<jump Love>>
===
Separating dialogue segments into nodes can aid in writing neater files that are easier to edit as they grow.
Sometimes it makes sense for the options presented or the outcomes of selecting different options to vary based on other things the player has done or said up until this point. This requires the use of logic and variables, which we’ll discuss next.
Next, learn about logic and variables.