# Writing scenarios

## 2. Kinds of lines

The extension is `.lim`. It's line-based UTF-8 text. Write one unit, such as a chapter, per file, and divide it with labels.

```
# north_road
// Flashback starts here
@chara Yuika smile at=left time=300ms
Outside the window, the rain was letting up.
Yui "Morning. You're up early today."
```

The kind of line is decided by how the line starts.

| Line starts with | Kind | Example |
|---|---|---|
| A speaker name immediately followed by `「` `『` `（` `(` | Dialogue | `ユイ「おはよう、今日は早いのね」` |
| A speaker name followed by `"` `“` (one half-width space may come between them) | Dialogue (English) | `Yui "You're early today."` |
| `@` | Command | `@chara Yuika smile at=left time=300ms` |
| `# ` | Label | `# north_road` |
| `//` | Comment (only at the start of a line; it can't be written at the end of a line) | `// Flashback starts here` |
| Empty line | Separator (no meaning) | |
| Anything else | Narration | `Outside the window, the rain was letting up.` |

Narration and dialogue are **one click per line**.
To stop in the middle of a line, write `{click}`; to break the line within the same page, write `{br}` (chapter 3).
To move on to the next line at the end of a line without waiting for a click, write `{noclick}` at the end of the line (chapter 3).
After a click moves on to the next page, the first command (a background, a sprite, a wait and so on) clears the previous page's name and text. With `ui.message.keepText` set to `true` in liminalia.json, they stay until the next text (for a single line, `keep-text=true` on `@bg`).

### What makes a line dialogue

Only lines that meet both of these conditions become dialogue.

1. The line starts with a speaker name registered in the project
2. Right after it comes one of `「` `『` `（` `(`, or a quotation mark `"` `“` follows it (you may write a single half-width space between the speaker name and the quotation mark)

Everything else is narration. `It was "love."` is narration, because "It was" isn't a speaker. (`「」` and `『』` are Japanese quotation marks, called corner brackets.)

Brackets and quotation marks are part of the text, and the game shows them as written (`ユイ「おはよう」` shows `「おはよう」`, and `Yui "Hello."` shows `"Hello."`).
The space before a quotation mark isn't part of the text, so the text starts at the quotation mark. To show the text without the outer brackets or quotation marks, set `ui.text.quotes` in liminalia.json to `strip` (appearance settings in chapter 4).

```
Yui "Hello."
Yui“Wait for me!”
Yui{name ???} "Who are you?"
```

- Only the start of the line is checked. The closing quotation mark isn't (just as with Japanese brackets, a line missing its closing mark is still dialogue). `“` closes with `”`, and `"` closes with `"`.
- Single quotation marks (`'` `‘`) don't make a line dialogue, because they can't be told apart from apostrophes in English text.
- Only a single half-width space is allowed. Two or more spaces, a full-width space or a tab make the line narration. With a Japanese bracket, even a single space before it makes the line narration.
- A line where a symbol follows the name, such as `Note: "x"`, and a line that starts with a name that isn't registered are narration.

The speaker name is the name shown in the name box (`Yui`, `???`, `Clerk` and so on). Register it in `speakers` in cast.json, separately from the character who owns the sprites (chapter 10).

**If a line meant as dialogue becomes narration, you get a warning.** A line where "a bracket or quotation mark starts after the name at the start of the line and closes at the end of the line" but which became narration gets the
`unknown-speaker` warning. The cause is usually one of the following, and if there is a speaker name with a similar spelling, it appears in the suggested fix.

- A misspelled speaker name
- A speaker you forgot to register
- A space between the name and the bracket (`ユイ 「…」`). For a quotation mark, a space that isn't a single half-width space (`Yui  "…"`, `Yui　"…"`)
- Habits from other script formats (`ユイ：「…」`, `【ユイ】「…」`, or `ユイ：…` with a registered speaker)
- The screenplay form with a half-width `:`. It warns only for a registered speaker's line, a line with a Japanese bracket after the colon (`ユイ:「…」`), and a line whose name starts with an uppercase letter when the same name appears on two or more lines of the same file (`Nora: "…"`). A single `Note: "x"` line stays narration without a warning
- A display name on a name that isn't registered (`Kai{name ???} "…"`). `{name …}` works only on a speaker's line, so adding the name to the speakers makes it dialogue

The suggested fixes are the line rewritten as dialogue (a replacement) and, for a name that isn't registered, "Add to speakers" (`add-speaker` in `fixes`).
To write narration shaped like dialogue on purpose, indent the start of the line with a full-width space (U+3000) (this is advice for Japanese projects; projects whose source language isn't Japanese aren't told to use a full-width space).

**Symbols typed with Japanese input still on are warned about too.** A full-width `＠` `＃` `／／` at the start of a line doesn't make a command, label or comment, and becomes text.
A full-width `＝`, as in `time＝300ms`, is still read but should be fixed (`fullwidth-symbol`; the suggested fix is the line with half-width characters).
A choice line written outside `@choice` (`- … -> target`) becomes text (`option-outside-choice`).
A `//` at the end of a line doesn't make a comment (`trailing-comment`; on command and choice lines it's an error and nothing from `//` on is read; on dialogue and narration it's a warning and it's shown as text).

### Changing the name in the name box (display name)

Keep the character as is and change only the name shown in the name box (a hidden identity such as "???", a name the player entered, a scene that reveals a real name, and so on).
Lip sync, dimming characters who aren't speaking, the balloon position, per-speaker volume, voice numbering and the name color keep working as the speaker.

```
Yui{name ???} "...Who are you?"
Hero{name {= game.player}} "I'm—"

@name Yui as=???
Yui "I'm no one worth naming."
Yui "...Not yet, anyway."
@name-off Yui
Yui "I'm Yui. Nice to meet you."
```

| How to write it | How long it lasts |
|---|---|
| Speaker{name Display name}「…」, Speaker{name Display name} "…" | That line only. Write `{name …}` right after the speaker name, before the bracket or quotation mark. Only characters and `{= expression}` can go inside |
| `@name speaker as=name` | Until `@name-off speaker` (omit the speaker for all). `as=(expression)` lets you use a variable (the value at the time this command runs is used) |

- `{name …}` on a line takes priority over `@name`.
- The keys of a line (translation, locked voice numbers, read status) are made from the speaker name and the text. The display name isn't part of the key, so a display name doesn't detach the translation or the voice number, and doesn't change the read status.
- In translation files, display names written as plain text are listed in `speakers` too, just like speaker names (Languages in chapter 10).
- The backlog, NVL, the chat screen and text-to-speech show the display name.

### Labels

- Write `# name`. A name can contain letters, digits, `_` and `-`.
- `#name` (no space) is an error (`bad-label`), with a suggested fix.
- Labels can't be placed inside `@if` (chapter 8).

### Indentation and escapes

- Half-width spaces and tabs at the start of a line are indentation and have no meaning.
- **Full-width spaces aren't removed.** Indent text with full-width spaces (U+3000, the usual way to indent a paragraph in Japanese).
- To show a symbol at the start of a line as text, put `\` before it (`\# is not a label`).

### Fixed line IDs (#line:)

At the end of a dialogue, narration or choice line, you can write `#line:ID` after a half-width space or a tab (like `#line:` in Yarn Spinner and `id` in Ren'Py).
An ID can contain letters, digits, `_` and `-`. Everything from `#line:` on isn't part of the text.

```
Yui "Morning. You're up early today." #line:3f2a91c0
Outside the window, the rain was letting up. #line:intro-rain
@choice
  - Check the door -> #door #line:0b7d44e1
@end
```

- On a line with an ID, the translation key and the key of the locked voice number no longer depend on the original text. Fixing the original a little doesn't detach the translation, and it keeps being used (Languages in chapter 10).
  The recorded voice number stays too, and lines whose original changed appear under "needs re-recording" in the recording script.
- `lim i18n --stamp-ids` gives IDs to lines without one (and moves the translation files and the locked voice numbers to ID keys too). You can also write them by hand.
- Using the same ID twice in the same file is an error (`duplicate-line-id`). A character that can't be used after `#line:` is a warning (`bad-line-id`), and the line ID part is shown as text too.
- To show `#line:` as text, write `\#line:`.
