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.
commitState
Section titled “commitState”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();discardState
Section titled “discardState”Discards any state changes made since the last commit.
discardState(): voidExample
discardState();processLabel
Section titled “processLabel”Runs any onLabel callbacks that match a lexia.
processLabel<T extends BlockLexia>(lexia: T): Promise<undefined | T | boolean>Example
processLabel(lexia);evaluateExpression
Section titled “evaluateExpression”Evaluates an expression from the screenplay.
evaluateExpression(expression: Expression): anyExample
dialogueLexia.expressions.forEach((expression) => { console.log(evaluateExpression(expression));});