NarraLeaf

SavedGame

This page is under construction.

Beta feature, subject to change.

interface SavedGame {
    name: string;
    meta: SavedGameMetaData;
    game: {
        store: { [key: string]: SerializedNamespaceData; };
        elementStates: RawData<ElementStateRaw>[];
        stage: PlayerStateData;
        services: { [key: string]: unknown; };
        stackModel: StackModelRawData;
        asyncStackModels: StackModelRawData[];
        history?: SerializedGameHistory[];
    };
}

Note: The save format is versioned through meta.version (currently 2). Saves written before the backlog was persisted omit history and load with an empty backlog.

name

The name of the saved game

meta

The metadata of the saved game, see SavedGameMetaData

game

Game data of the saved game

store

Every namespace's contents, keyed by namespace name. Values are stored in their tagged form, see SerializedNamespaceData.

This covers both the namespaces registered with story.registerPersistent and the scene locals behind scene.local.

Read this through Storable / Namespace rather than by hand. A stored value is not the value itself but a {type, data} wrapper, which is what lets a Date survive JSON.

elementStates

The state of every element in the story, each entry carrying the element's id alongside its data.

stage

The state of the player, including the scenes and displayable elements currently on stage.

services

The serialized state of every service registered with story.registerService.

stackModel

The main execution stack, which is where the game resumes from when the save is loaded.

asyncStackModels

The execution stacks running alongside the main one — the actions started by Control.doAsync and Control.allAsync.

history

The persisted backlog (save format v2+). Each entry pairs the rendered say/menu content with a stable action id and a self-contained snapshot of the game at that line, which is what lets liveGame.getHistory() return a full backlog after a load and liveGame.restoreToHistory(token) jump back to any of these lines. Optional: legacy saves have no history, and a save whose story has since changed drops entries whose action no longer exists.

On this page