Skip to content

YarnScript

Henrique Souza Moraes edited this page Feb 19, 2024 · 15 revisions

Yarn is a language utilized in games like Far From Noise, Knights and Bikes, and Night In The Woods. It's crafted to be user-friendly for writers with minimal programming expertise. Yarn doesn't presuppose how a game exhibits dialogue or how players select responses, resulting in a versatile tool.

YarnScript has its own documentation, which you can access here.

One of Love Garden's most utilized libraries is Chatterbox, a GameMaker implementation of the Yarn language. You can find more information about Chatterbox here.

Main Structure

Every yarn file must end with .yarn. The content of the file is filled with nodes.

Below is the template for a node:

title: 
---
(Dialogue lines 1)
(Dialogue lines 2)
(Dialogue lines 3)
(Dialogue lines 4)
(etc...)
===

The file can contain multiple nodes.

There are a couple of special titles, used only for redirecting with the <<jump>> command. They are:

  • Morning
  • Noon
  • Afternoon
  • Night

Here's how you would use them:

title: Morning
---
<<jump WakeUp>>
===

title: Noon
---
===

title: Afternoon 
---
<<jump Chitchat>>
===

title: Night
---
<<jump GoodNight>>
===

The nodes Morning, Noon, Afternoon and Night are redirection nodes. Their sole function is to call the <<jump>> command to redirect to the right node depending on current daytime. The nodes WakeUp, Chitchat and GoodNight are custom nodes, the writers have the freedom to create custom titles for each specific scene.

Speaker

  • Format: CHARACTER-NAME:

  • Example:

CARU: The sun is already high in the sky, the birds are mocking you.

Obs: For consistency when displaying the text inside the nametag, the character names should be all in uppercase.

Gender Flexion in PT-BR

When writing in PT-BR, it is necessary to use opening and closing tags in ALL words that flex gender.

Example:

???: Hora de levantar, <dorminhoco>!

Generally, the standard is to write flexed adjectives and pronouns in the masculine.

The exception to this rule is for definite articles ("o", "a", "ê"), which use <x>.

The reason for this is that we need to differentiate the characters of articles ("o"/"a"/"ê") from those used at the end of adjectives ("o"/"a"/"e").

Example:

PLAYER: Pelo menos não sou <x> <único>.

During the game's execution, all these strings will be dynamically converted to the appropriate flexion according to the pronouns chosen by the player.

The following characters, when enclosed in <>, will be converted into:

ELU ELA ELE
x ê a o
ele elu ela ele
dele delu dela dele
seu sue sua seu
meu minhe minha meu
esse êssu essa esse
co* que* ca* co*
go* gue* ga* go*
o* e* a* o*

(* These apply only at the end of words.)

Dialogue Options

Format: ->

Example:

Is there something blooming between you?
-> I think there's a passion sprouting...
    Your mind returns to reality\nwhen you reach your destination.
-> Nah. We're just classmates.
    Your mind returns to reality\nwhen you reach your destination.
-> I don't want anything with them.
    Your mind returns to reality\nwhen you reach your destination.

Note: Whenever you create an option, you'll be creating a branch within the scene, and it can take different paths. That's why indentation (tab) is important.

Node Change within Yarn (JUMP)

Format: <<jump(nodeTitle)>>

Example:

title: Start
---
-> So, are you going to stay planted there?
    ???: Ah... uh... planted haha, got it...
    <<jump Professor>>
===
    
title: Professor
---
???: What's all this talk outside the classroom?
<<character("fern")>>

IF x ELSEIF x ELSE x ENDIF

Format: <<if (expression)>>

Examples:

<<if flag("favePlace")>>
    <<nextRoom("rm_ecopark")>>
<<else>>
    <<nextRoom("rm_campus_map")>>
<<endif>>
<<if ((wilting() > 8) && (growth() >= 3))>>
    <<nextRoom("rm_thoughts")>>
<<elseif (growth() < 3)>>
    <<nextRoom("rm_dormroom")>>
<<else>>
    <<nextRoom("rm_school")>>
<<endif>>

Clone this wiki locally