1681-engine / index / DialogueRunner
Class: DialogueRunner ​
Defined in: src/dialogue/DialogueRunner.ts:38
Runs a DialogueScript: hands the game one step at a time — a line, a set of choices, the end — and moves on when the game says the line was read (next) or a choice made (choose). It draws nothing: the game's own box shows a ShownLine however it likes (a typewriter, a portrait from tags).
const talk = new DialogueRunner(script, { vars: save.flags, onCommand: (name, args) => game.run(name, args) });
let step = talk.start();
// on a press: step = step.type === 'line' ? talk.next() : talk.choose(picked);Constructors ​
Constructor ​
new DialogueRunner(script, options?): DialogueRunner;Defined in: src/dialogue/DialogueRunner.ts:47
Parameters ​
| Parameter | Type |
|---|---|
script | DialogueScript |
options | DialogueOptions |
Returns ​
DialogueRunner
Properties ​
script ​
readonly script: DialogueScript;Defined in: src/dialogue/DialogueRunner.ts:48
vars ​
readonly vars: Record<string, unknown>;Defined in: src/dialogue/DialogueRunner.ts:39
Accessors ​
at ​
Get Signature ​
get at(): string | null;Defined in: src/dialogue/DialogueRunner.ts:71
The node the dialogue is in, or null once it has ended.
Returns ​
string | null
current ​
Get Signature ​
get current(): DialogueStep;Defined in: src/dialogue/DialogueRunner.ts:66
The step showing now.
Returns ​
Methods ​
choose() ​
choose(index): DialogueStep;Defined in: src/dialogue/DialogueRunner.ts:94
Picks a choice by its index (as shown). A locked or unknown index changes nothing.
Parameters ​
| Parameter | Type |
|---|---|
index | number |
Returns ​
evaluate() ​
evaluate(source): ExprValue;Defined in: src/dialogue/DialogueRunner.ts:117
The value of an expression over this dialogue's variables, for a game that shares the language.
Parameters ​
| Parameter | Type |
|---|---|
source | string |
Returns ​
jump() ​
jump(node): DialogueStep;Defined in: src/dialogue/DialogueRunner.ts:107
Jumps to a node from outside (the game's own event broke in).
Parameters ​
| Parameter | Type |
|---|---|
node | string |
Returns ​
next() ​
next(): DialogueStep;Defined in: src/dialogue/DialogueRunner.ts:87
The line showing was read: on to the next line, the choices, or wherever the node leads.
Returns ​
restore() ​
restore(save): DialogueStep;Defined in: src/dialogue/DialogueRunner.ts:132
Puts a saved dialogue back where it was, without running the node's set and do again.
Parameters ​
| Parameter | Type |
|---|---|
save | DialogueSave |
Returns ​
save() ​
save(): DialogueSave;Defined in: src/dialogue/DialogueRunner.ts:121
Returns ​
start() ​
start(node?): DialogueStep;Defined in: src/dialogue/DialogueRunner.ts:81
Begins at node (default the script's start, else its first node).
Parameters ​
| Parameter | Type |
|---|---|
node | string | undefined |
Returns ​
stop() ​
stop(): DialogueStep;Defined in: src/dialogue/DialogueRunner.ts:112
Ends the dialogue now.
Returns ​
visited() ​
visited(node): number;Defined in: src/dialogue/DialogueRunner.ts:76
How many times a node was entered.
Parameters ​
| Parameter | Type |
|---|---|
node | string |
Returns ​
number