Split a story across several Scripts#
As a game grows, one Script per character turns into long files that repeat each other. @script runs another Script at that point in the conversation, then returns to the next line. You'll share the village's gossip between two characters, and split the elder's quest into a short Script for each stage.
Before you begin#
Complete Build a merchant conversation and Build a quest giver. This guide edits the guard's, Odile's, and the elder's Scripts.
Write a shared Script#
Gossip is the same whoever tells it, so it belongs in one place. Create a Script named Village Gossip with a Label for each topic:
# wolves
The wolves came down from the hills when the snow melted early.
Nobody has seen a winter that short in forty years.
# elder
Maren has led Ashford since before the wall was built.
They say she has lost something precious, and won't say what.These lines have no speaker, so they read as narration whichever character passes them on.
Then register the Script so other Scripts can call it. In the Village Compendium, open the Scripts section and add an entry:
| Field | Value |
|---|---|
| Script | gossip |
| Script Asset | Village Gossip |
Run it from a conversation#
Open the guard's Gate Conversation, which ends with his random remark, and add these lines at the end:
Guard: You'll hear plenty of talk in the village.
@script gossip
Guard: Make of that what you will.When the conversation reaches @script gossip, it pauses, plays Village Gossip from its first line to its last, and then continues with Make of that what you will. The interface doesn't close in between, so the player sees one continuous conversation.
Start at a Label#
A character may only know part of the gossip. Add a Label identifier after the Script identifier to start there instead of at the top. Give Odile a choice in Potion Stall:
* What do people say about the elder?
Merchant: Oh, you'll hear all sorts.
@script gossip elder
@go shopOdile's version starts at # elder and skips the wolves entirely, then returns to her shop.
End a topic with @exit#
A Label marks where a Script can start, not where it stops. The guard starts at the top, so he tells the wolf gossip and carries on through # elder to the end of the file. To make each topic stand on its own, end it with @exit:
# wolves
The wolves came down from the hills when the snow melted early.
Nobody has seen a winter that short in forty years.
@exit
# elder
Maren has led Ashford since before the wall was built.
They say she has lost something precious, and won't say what.Inside a Script that @script started, @exit ends only that Script, and the conversation returns to the caller. The guard now stops after the wolves and says Make of that what you will. To have him tell both topics, add @script gossip elder on the line below his first @script.
Split a long conversation#
The elder's Lost Ring Script is short now, but each stage tends to grow: more dialogue, more choices, more reactions. Move each stage into its own Script and keep the original as a router:
- Create Scripts named
Ring OfferandRing Reward. Move the lines of the offer branch and the reward branch into them, and remove the indentation they had inside their branch, so each Script's first line starts at the left edge. - Register them in the
VillageCompendium asring-offerandring-reward. - Replace the branches in
Lost Ringwith calls:
@if ring-quest-done
Elder: My ring hasn't left my finger since you brought it back. Thank you.
@or ring-quest-active
@if has-ring
@script ring-reward
@else
Elder: Any luck with my ring? I lost it somewhere near the old well.
@else
@script ring-offerThe router reads like a summary of the quest, and a writer working on the reward opens a Script that contains nothing else.
What a called Script shares#
A called Script runs on the same Dialogue component as its caller, but it's still a separate file:
| Shared with the caller | Separate from the caller |
|---|---|
| The interface, which stays open. | Labels: @go only reaches Labels in its own Script. |
| Source and Target, so Commands act on the same characters. | The Local Compendium: each Script reads its own, plus the Dialogue component's and the global ones. |
The visited-line memory and @select progress of the Dialogue component. |
@exit, which ends only the Script it's written in. |
Keep shared definitions out of a Script's Local Compendium
An Actor or Command defined in the caller's Local Compendium isn't visible to the Script it calls. Put anything both need in a global Compendium, or on the Dialogue component.
If @script names an identifier that no Compendium defines, Dialogue logs Unable to find script in the Console and continues with the caller's next line.
Verify the result#
- Talk to the guard. Confirm that both pieces of gossip play, then Make of that what you will.
- Ask Odile about the elder. Confirm that she tells only the elder gossip and returns to her shop.
- Run through the elder's quest again, as in Build a quest giver, and confirm that every stage plays as before.
Where to go next#
- Compendiums — register Scripts in a Compendium.
- Language syntax — the
@scriptCommand and its optional Label. - Localization — export each Script's lines for translation.