Saves & settings

One save file holds everything about a playthrough. Saves carry a version number, and old saves are upgraded step by step when loaded.

What's in a save

PartHolds
dataYour own data, shaped by src/content/save/data.ts: stats, flags, inventory, anything you add
engineWhat the engine tracks: map and exact position, play time, clock, placed structures and props, prop memory, quests, relationships, money, shop stock, party (levels, HP/MP, equipment, skills taught with game.party.learn), which items are switched on (a lit lantern), journal, a thumbnail picture, (visual novel mode) where the story is in its routes, and (mid-scene saves) the scene record
version, gameVersion, savedAtSave format version (a number), the game's version (from package.json, for information), date

Not in saves: settings, achievements, gallery/scene unlocks and read lines. Those belong to the device. So do the flowchart's reached and picked boxes (Routes & flowchart).

Your saved data

// src/content/save/data.ts — keep this file free of game imports
export const initialData = () => ({
  stats: { health: 100, hunger: 0 },
  flags: {} as Record<string, boolean | number | string>,
  inventory: {} as Record<string, number>,
  visitedCaves: [] as string[],          // add anything; then add a migration (below)
})
export type GameData = ReturnType<typeof initialData>
game.state.get().stats.health
game.state.update((d) => { d.stats.health -= 10 })     // immer: just change it
const health = useGameData((d) => d.stats.health)       // React, from '@/core/state'
In React, select plain values or an object/array that already exists (useGameData((d) => d.inventory)) and work with it in the component. Never build a new array or object in the selector (Object.entries(d.inventory), d.list.filter(…)): it re-renders forever. useShallow doesn't fix that either.
data.ts must not import game code: the saved data type would then depend on the game, and TypeScript runs into circular types.

Slots, autosave, files

game.save.save('slot1')                  // false if saving isn't possible right now
await game.save.load('slot1')
game.save.list()                         // every slot with info, thumbnail, or an error
game.save.list(['slot1', 'slot2'])       // only these
game.save.autosave()                     // write the 'auto' slot now (false if it was skipped)
game.save.quickSave()                    // write the 'quick' slot, with a message
await game.save.quickLoad()              // asks, then loads it
game.save.latest()                       // the newest save (for "Continue")
game.save.delete('slot2')                // false when the save is locked
game.save.setNote('slot1', 'Before the festival')   // the player's comment ('' removes it)
game.save.setLocked('slot1', true)       // can't be overwritten or deleted until unlocked
await game.save.exportBackup()           // every slot + persistent data in one file (see below)
game.save.canSave()                      // see below
game.save.whyCantSave()                  // a short reason ("in a minigame"), or null when saving works
game.save.hasUnsavedChanges()            // progress that is in no manual save yet
game.save.onSaved((slot) => { … })       // after every save (again once its picture is ready); returns an unsubscribe
await game.save.newGame()

Autosave

// src/content/save/index.ts
slots: 197,                // manual slots
autosave: {
  mapChange: true,         // arrived on another map
  eventEnd: true,          // a scene finished
  minigameEnd: true,       // a minigame or battle finished
  windowsClosed: true,     // the last window closed (shop, inventory, party...)
  appHidden: true,         // the game went to the background or is closing
  everyMinutes: 5,         // of play without any save (0 = never)
},

Fewer slots in the browser

A browser keeps far less than a disk, so the web version offers only as many slots as fit. Desktop and Android store files and offer every slot. The sizes (in characters) are in src/content/save/index.ts:

browser: {
  storage: 2_600_000,  // the smallest common browser (Safari); Chrome and Firefox give twice this
  reserved: 1_000_000, // settings, read lines, unlocks, achievements, anything added later
  perSave: 130_000,    // one save: its picture plus its data
},

Save pictures

Each save holds a small picture of the game screen as the player saw it: the map with the scene (characters, text box) or the HUD on top, without windows, touch buttons or the black bars around the screen. Size and quality: thumbnail: { width: 256, quality: 0.72 } in src/content/save/index.ts.

Where saves are stored

Saving is automatic on every system: no dialog, the data just lands in the right place. Settings and progress (read lines, unlocks, achievements) are stored the same way, next to the saves.

SystemFolder
Windows%APPDATA%\<id>\game\ (C:\Users\<you>\AppData\Roaming\<id>\game\)
Linux~/.config/<id>/game/ (or $XDG_CONFIG_HOME/<id>/game/)
macOS~/Library/Application Support/<id>/game/
AndroidThe app's private folder: /data/data/<appId>/files/game/. Other apps and file managers can't see it (needs adb on a debug build). Uninstalling the app deletes it.
BrowserlocalStorage, keys <id>:save:<slot>, <id>:settings, <id>:persistent. Per browser and per site address. If the browser blocks site data, everything stays in memory and is gone when the page closes.

The Saves window shows which one is in use at the bottom (Saved to: files on this device, this browser (localStorage), or Not saved: memory only with a warning). In code:

game.save.storage() // { kind: 'files' | 'browser' | 'memory', failing, limited }
// failing: a file could not be written, or the browser's storage is full
// limited: the browser offers fewer slots than the game has

Inside the folder:

game/saves/auto.json      # autosave
game/saves/slot1.json     # slot1, slot2, ...
game/settings.json
game/persistent.json      # read lines, unlocks, achievements, title screen

Backing up and restoring on every system

Saves leave and enter the game only as one backup of everything: a single save can't be exported, and a single save file is refused on import (with a message). That keeps progress, unlocks and saves together.

SystemExportImport
Desktop"Save as" dialog (starts in Documents)"Open" dialog, or drop a file on the Saves window
AndroidShare sheet: Files, Drive, a chat, …The system file picker (shows every file type)
BrowserA downloadFile picker, or drop a file on the Saves window

A backup made on one system restores on any other, and old saves in it are upgraded (migrations).

Backups (everything in one file)

What players think of as "my save": all save slots plus the persistent data (read lines, unlocks, achievements). Settings are left out; they belong to the device.

await game.save.exportBackup()            // <id>-backup-2026-11-10.json; false if cancelled

game.save.fileKind(text)                  // 'backup' | 'save' | null
const plan = game.save.readBackup(text)   // checks + upgrades everything, stores nothing yet
plan.slots                                // the saves in it (SlotInfo, already upgraded)
plan.existing                             // slots with a save on this device now
game.save.applyBackup(plan)               // restores it; -> the slots that now hold a save

Importing a backup is a full replace, never a merge. The device ends up exactly as the backup was: every save slot is replaced, slots the backup doesn't have are emptied, and the persistent data is replaced. Lines read, unlocks and achievements that aren't in the backup become unseen again. So loading an old backup really goes back in time.

{
  "format": "<id>-backup",
  "version": 1,                 // layout of this file (engine only, see below)
  "persistentVersion": 1,       // version of "persistent"
  "gameVersion": "0.1.0",
  "savedAt": "2026-11-10T12:00:00.000Z",
  "saves": { "auto": { …save file… }, "slot1": { … } },
  "persistent": { "read": {}, "unlocked": {}, "achievements": {} }
}

New game and loading hooks

// src/content/save/index.ts
export default defineSave<GameData>({
  initial: initialData,

  // After data is reset: put the player somewhere. (Visual novel mode, src/content/config/mode.ts, skips
  // this: a new game starts the common route, and a save loads back into its route.)
  newGame: (game) => {
    game.party.add('hero')
    return game.maps.go('heaven/before_god', { spawn: 'start' })
  },

  // Every loaded save, after migrations, before the game uses it: last fixes.
  beforeLoad: (save) => {
    save.data.stats.health = Math.min(100, Math.max(0, save.data.stats.health))
    return save
  },

  // Once the loaded game is on screen.
  afterLoad: (game) => { if (game.party.members().length === 0) game.party.add('hero') },

  slots: 197,
  autosave: { mapChange: true, eventEnd: true, everyMinutes: 5 },   // see Autosave above
})

Versions and migrations

Stored data has a version number, so a newer game can upgrade what an older one wrote. Everything is at version 1 now and there are no migration files. Only add one once the game is out and a change would break data players already have.

WhatUpgrade filesCurrent version
Save files (save/data.ts + engine state)src/content/save/migrations/vN.tsHighest N, or 1
Persistent data (read lines, unlocks, achievements)src/content/save/persistent_migrations/vN.tsHighest N, or 1
Backup file layoutnone (engine; you shouldn't need to touch it)BACKUP_VERSION in src/core/save/backup.ts

The game's own version (package.json) is only shown to players. It never decides how data loads.

Do I need a migration?

ChangeMigration?
New flag, quest, item, map, event, achievementNo. They start at their defaults in old saves.
New field in data.ts that is fine at its initial valueYes, a one-liner that adds it (old saves don't have it).
Field renamed, moved, removed, or its type changedYes.
A map, event or item id renamed that saves refer toYes, rename it in old saves (engine.map.id, inventory keys…).
Before the first releaseNo. Change data.ts freely; just delete your own test saves.

Adding v2 (then v3, v4…)

  1. Change the shape in save/data.ts (here: hp renamed to health).
  2. Create the next file. The first one is v2.ts; it upgrades a version 1 save to version 2. The next is v3.ts, and so on. No gaps. Nothing else to register: the file is found by its name.
    // src/content/save/migrations/v2.ts
    import { defineMigration } from '@/core/save/define'
    
    // Version 1 -> 2: `hp` was renamed to `health`.
    export default defineMigration(({ engine, data }) => {
      const { hp, ...stats } = data.stats ?? {}
      return { engine, data: { ...data, stats: { ...stats, health: hp ?? 100 } } }
    })
  3. Add an example of a version 1 save to OLD_SAVES in src/content/save.test.ts. pnpm test then checks it upgrades to exactly the shape of a new game (and fails until the example is there):
    const OLD_SAVES = [
      { version: 1, data: { stats: { hp: 42, hunger: 0 }, flags: {}, inventory: {} } },
    ]
  4. Never edit a migration once players have it. Fix mistakes with the next number.

Persistent data migrations

Same idea, for the data kept across all saves (read lines, unlocks, achievements, and your own under game, see below). The stored copy on each device and the copy in backups are upgraded by the same files. You only need one to rename a value of your own, or change its kind; a value added later simply starts at its value.

// src/content/save/persistent_migrations/v2.ts — version 1 -> 2: unlocked split into gallery + scenes
import { definePersistentMigration } from '@/core/save/define'

export default definePersistentMigration((data) => {
  const { unlocked = {}, ...rest } = data
  return { ...rest, gallery: unlocked, scenes: {} }
})
  1. Change PersistentState and its empty() defaults in stores/persistent.ts.
  2. Add the vN.ts file above (first one is v2.ts).
  3. Add an example to OLD_PERSISTENT in src/content/save.test.ts.
  4. Nothing else: stored data and backups both go through the same files, and restoring a backup replaces the data whole.

Persistent data from a newer game (after downgrading) is kept as it is rather than thrown away.

Leaving: title screen and quit

Going back to the title screen (or quitting the desktop app) asks first when there is progress that is not in a manual save (autosaves don't count; playtime and the clock don't count either):

await game.session.leave('title')   // or 'quit'; resolves false if the player stayed
// Asks "Save first / Leave without saving / Cancel" when saving is possible,
// otherwise "Leave anyway / Cancel" with the reason saving isn't possible.

// Your own question, with buttons (a small window):
const choice = await game.dialog.ask('Really?', { yes: 'Yes', no: 'No' })  // null if closed

New Game+

Starting over while keeping some of what was earned. Not offered in visual novel mode (the title menu hides it there). What is kept is remembered outside the save slots at the moment New Game+ is unlocked, so it does not depend on any save.

// src/content/config/newgameplus.ts
export default defineNewGamePlus({
  enabled: true,
  unlock: 'ending',          // any ending() unlocks it; 'manual' = only game.save.unlockNewGamePlus()
  carry: {
    party: true,             // levels, XP, equipment, learned skills
    money: 1,                // × the money (0 = none)
    items: true, itemsExcept: ['letter'],
    codex: true, relationships: false, difficulty: true,
    flags: [],               // flag names to keep
    data: [],                // other keys of content/save/data.ts copied whole
  },
})

game.save.unlockNewGamePlus()   // remember the game as it is now (again = replace)
game.save.newGamePlusReady()    // the title menu uses this (content/start.ts)
await game.save.newGamePlus()   // a new game with the carried things; your newGame runs after
game.save.cycle()               // 0 = first playthrough, 1 = first New Game+, … (saved)

Data outside the save slots

Kept per device across all saves and new games. Persistent data goes into backups; settings don't.

WhatWhere
Settingsgame/settings.json (browser: <id>:settings), see where
Read lines (for Skip), gallery, scene, music room and title screen unlocks, the picked title screen, achievements, what New Game+ carries overgame/persistent.json (browser: <id>:persistent); the dev panel can reset it

Your own data across saves

For things that belong to the player, not to one save ("cleared once", how many endings were seen, a secret opened from the title screen): src/content/save/persistent.ts, each with its starting value (its type comes from it). Data for one playthrough goes in data.ts instead.

// src/content/save/persistent.ts
export default definePersistent({
  clearedOnce: false,
  endingsSeen: 0,
})

game.persistent.get('clearedOnce')          // false
game.persistent.set('clearedOnce', true)
const cleared = usePersistent('clearedOnce') // React (from '@/core/managers/persistentGame')

Settings

Setting
volumemaster, music, sfx, voice (0..1)
textSpeedLetters per second; the top of the slider means instant
autoDelay, skipUnread, skipAfterChoice, skipEffectsAuto-play pause; Skip also skips unread lines; Skip comes back after a choice; fades and animations finish at once while skipping
fullscreenApplied on start (browsers: on the first key press)
screenRatio, cursorAutoHideGame screen shape; seconds before an idle mouse hides. Choices and defaults: content/config/screen.ts
language'source' or a language folder id
bindingsThe player's own keys/buttons per action
showDevPanelDev builds
import { useSettingsStore } from '@/core/stores/settings'
const speed = useSettingsStore((s) => s.textSpeed)
useSettingsStore.setState((s) => { s.volume.music = 0.5 })

Settings added later get their default value automatically.

Erase all data

The Settings window ends with Erase all data. After a confirmation it removes everything this game stored (the files in the save folder, or the localStorage keys in a browser) (all save slots, settings, read lines, unlocks, achievements) and reloads the game. There is no undo.

await game.session.wipeAllData()   // resolves false if the player cancelled; reloads on confirm
// Anything stored with game storage (src/core/save/storage.ts) is erased too.