Skip to content
This repository has been archived by the owner on Dec 21, 2021. It is now read-only.

How to write in Yarn

Robert Yang edited this page Jul 16, 2019 · 26 revisions

Nodes and Lines

Yarn files (files ending with .yarn.txt) are text files segmented into nodes (like passages in Twine). Think of each node like a scene, and each line of the node is like a separate line of dialogue. The player reads one node at a time, one line at a time.

Robert: Hello world.
Eddie: ... Who are you talking to?
Robert: The world!
World: Hey Robert.

Node Options

To make players choose between going to different nodes, you can use a node option like this: [[OptionLabel|NodeName]]. So to make the player go to a node called "Cookies" or a node called "Candy", you would write:

Do you want cookies or candy?
[[I choose cookies.|Cookies]]
[[I choose candy.|Candy]]

IMPORTANT NOTE: By design, Yarn Spinner only shows node options to the player at the very end of the node, after all the dialogue is finished.

Shortcut Options

You can also make players choose an option by putting -> before each option. This is called a shortcut option.

When you indent (type 4 spaces or press [TAB]) after a shortcut option, those indented lines become a response / branch of dialogue. This is faster and more convenient than creating another node, which is why we call it a shortcut option.

You can also nest another set of options after each option. Notice how picking "I choose cookies" will lead the player to another set of options, "Fresh baked cookies" and "Chocolate chip cookies":

Do you want cookies or candy?
-> I choose candy.
     Sorry, we don't have any candy.
     It was bad candy anyway. It wasn't fresh.
-> I choose cookies.
     What kind of cookies do you want?
     -> Fresh baked cookies.
          Are you saying my cookies aren't fresh?
     -> Chocolate chip cookies.
          No chocolate chip. Don't be so basic.

With shortcut options, you can quickly create dozens of choices, or even a hundred branches, all within a single node.

Shortcut Options as Node Options

If you type [[NodeName]] (with no OptionLabel) then Yarn will just jump to that node. That means you can use shortcut options as if they were node options, except with more control and flexibility.

Do you want cookies or candy?
-> I choose cookies.
    Now jumping to the cookies node...
    [[Cookies]]
-> I choose candy.
    [[Candy]]

More information

And that's pretty much the basics of writing in Yarn and giving choices! If you want to do more, read the Yarn Spinner documentation: