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 Aug 26, 2018 · 26 revisions

Every Yarn script file (.yarn.txt file) is made of chunks called nodes (like passages in Twine). The player can only read one node at a time.

In each node you can show dialogue, run commands, or let players make a choice. Each line is a separate line of dialogue:

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

Node Options

To make players choose between 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 only shows node options 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 (by pressing [TAB]) on line(s) after a shortcut option, you can create a response or branch of dialogue without creating another node, which is why we call it a shortcut option.

You can also nest another set of shortcut options after another shortcut option, like with the "Fresh baked cookies" and "Chocolate chip cookies" choices below:

Do you want cookies or candy?
-> 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.
-> I choose candy.
     Sorry, we don't have any candy.
     It was bad candy anyway. It wasn't fresh.

Shortcut options are very flexible. I like using them instead of node options, actually. If you type [[NodeName]] (with no OptionLabel) then Yarn will jump to that node.

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:

  • Yarn Spinner: using if/else and variables
  • Yarn Spinner: advanced features
Clone this wiki locally