Skip to content

Advanced

These functions are the building blocks Inkweaver uses to process screenplay content. Most scripts and plugins never need them. They’re useful when you’re decorating commands that change how Inkweaver handles the screenplay.

Saves the current state as a new step in the reader’s history.

commitState(): Promise<void>

Inkweaver commits state for you as the story moves. Call this only if you’re writing a command that changes state and needs those changes saved as their own step.

If the step can’t be saved, the changes stay uncommitted, and the next commitState tries again.

Example
await commitState();

Discards any state changes made since the last commit.

discardState(): void
Example
discardState();

Runs any onLabel callbacks that match a lexia.

processLabel<T extends BlockLexia>(lexia: T): Promise<undefined | T | boolean>
Example
processLabel(lexia);

Evaluates an expression from the screenplay.

evaluateExpression(expression: Expression): any
Example
dialogueLexia.expressions.forEach((expression) => {
console.log(evaluateExpression(expression));
});