mwg API
    Preparing search index...

    Class StageScript

    Runs a scene.

    run resolves when the list is exhausted, so a caller can simply await a conversation and carry on afterwards, which is what makes a cutscene readable at the call site instead of a chain of callbacks.

    import { StageScript, DialogueStage, type StageCommand } from '@datamoc/mw_games/two-d';
    import { WindowStack } from '@datamoc/mw_games/two-d';
    import type { Texture } from 'pixi.js';

    declare const backdropTexture: Texture;

    const stage = new DialogueStage(1280, 720);
    const windows = new WindowStack();
    const script = new StageScript({ stage, windows, backdrop: () => backdropTexture });

    const commands: StageCommand[] = [
    { backdrop: 'town-square' },
    { show: 'hero', at: 'center' },
    { say: 'A new adventure begins.', as: 'hero' },
    ];
    await script.run(commands);
    Index
    skipSeen: boolean = false

    When true, a line whose exact text has already been shown once this script's lifetime reveals at once and advances on its own instead of waiting for confirm - common visual-novel "skip already-read text". A line with choices never skips: those always wait for a real answer.

    state: ScriptState = ...
    • Re-shows the most recently completed line for review: a player-facing "back" a game can wire to a button or a scroll gesture. This is read-only - it does not let a past choice be re-picked or replay any side effect (show/hide/call) around it, only the words themselves, the bounded and honestly-scoped half of "rollback" this offers. Resolves to false when there is nothing in history yet.

      Returns Promise<boolean>

    • Puts one line in front of the player and resolves with their answer.

      Protected rather than private on purpose: this is the seam for a game that presents dialogue its own way (a different box, a voice line, a test harness) without reimplementing the sequencing above.

      Parameters

      • text: string
      • as: string | undefined
      • Optionalspeaker: string
      • Optionalchoices: Choice[]

      Returns Promise<unknown>