The engine is responsible for keeping the parsed story data and the current state.

Properties

applyTheme: ((theme) => void) = applyTheme

Applies a Theme to the document.

Type declaration

    • (theme): void
    • Parameters

      Returns void

currentPassage: Readable<Passage>

Tracks the current Passage.

globals: {} = {}

Global story variables that get automatically saved and loaded can be put here.

Type declaration

    history: Writable<History> = ...

    The History of past/future Passages and their local variables, and the index into the history list for the current Moment.

    loading: Writable<boolean> = ...

    Whether a load is in progress.

    saveDB: SaveDB

    The saves database for slotted saves and the autosave.

    title: Writable<string>

    The story title as extracted from the <title> element. Can be changed by the story itself after loading to change the displayed title at runtime.

    engine: Engine = ...

    The global Engine singleton.

    Accessors

    Methods

    • Adds a new Moment to the history with the specified Passage and sets it as the current Moment. Optionally you can pre-set local variables.

      Parameters

      • passage: Passage
      • locals: object = {}

      Returns void

    • Sets the initial History if no history could be found in session storage. Initiates an autoload if autoload is enabled and no session history is found.

      Parameters

      Returns void

    • Tries to save the current save in session storage, if small enough and enabled.

      Returns void