Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Documentation added for arbitrary variable names. #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/writing/expressions-and-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ This sets the variable `$suspect_steve` to the number 1.

If a variable hasn't been set, it will have the value `null`.

### Variable Names

Variable names must start with a letter, and can be composed of letters, numerals and the underscore character. If this is not sufficient for your purposes, you can "escape" a variable name using backticks to supply an arbitrary variable (as long as it doesn't contain a backtick). For example:

```yarn
Mae: Oh god. Steve Scriggins.
<<set $`suspect_steve.noticed` to 1>>
Lori: Yeah. Him.
```

### Variables and your game

Yarn Spinner doesn't manage the storage of information in variables itself. Instead, your game provides a *variable storage* object to Yarn Spinner before you start running dialogue.
Expand Down Expand Up @@ -81,4 +91,4 @@ Character: You've spoken to me {$times_spoken} times today!

{{<note>}}
To make your lines have correct grammar, you can use [format functions]({{<ref "syntax.md#format-functions">}}) to select content in a line based on an expression.
{{</note>}}
{{</note>}}