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
| Part | Holds |
|---|---|
data | Your own data, shaped by src/content/save/data.ts: stats, flags, inventory, anything you add |
engine | What 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, savedAt | Save 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'
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()
- Slots:
auto,quick,import, thenslot1,slot2… as many asslotsinsave/index.ts(197, so the window has 200 boxes). Where they are stored: below. - Quick save: F5 writes the
quickslot, F9 loads it after asking (actionsquickSave/quickLoadinsrc/content/config/input.ts); in scenes also the Q.Save / Q.Load buttons. It works wherever saving works, and the slot shows in the Saves window. - Autosave writes the
autoslot at the moments switched on insave/index.ts(below). - When saving works: on a map (not during a map change, minigame or title screen), or in a scene while a line or choice waits for the player (see mid-scene saves). Not during a scene replay from Extras.
- The Saves window (
windows/saves) is a grid of boxes, 5 × 4 a page (4 × 3 on a short screen such as a phone): the save's picture with its name, chapter (or place, without one), play time and date on top. Pressing an empty box saves there; a filled one shows its details (type, play time, date, the map's title and, during a scene, the event's title, then the chapter title and description) and asks Load / Overwrite / Delete. The first two boxes are the autosave and the quick save. Left / right at the edge of the grid, Q / R, LB / RB or the arrows at the bottom change the page. It also has Back up all, Import backup (or drag & drop a backup), and on desktop Open folder. Grid size and the text strip's colours are constants at the top of the file.
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)
},
- Set one to
falseto switch it off; removeautosavefor none. - A moment where saving isn't possible (mid-scene, in a minigame, on the title) is skipped, not retried.
- Loading a save or starting a new game never autosaves, so loading an old save doesn't replace the autosave.
- Your own moments (slept at the inn, beat a boss):
game.save.autosave().
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
},
- Boxes that fit = (
storage−reserved) ÷perSave= 12: the autosave, the quick save and 10 manual slots. - The numbers are safe, not tight: a save is about 8,000 characters in the demo, so each can grow 15 times. Lower
perSavefor more slots, raise it if your saves get big. Removebrowserto offer every slot. - Notes and locks: picking one of the player's own slots offers Add note / Edit note (up to 40 letters:
noteMaxinsrc/content/save/index.ts; typed with the keyboard, the phone's keys, or on-screen keys on a controller) and Lock / Unlock. The note shows on the box instead of the time; a locked box has a padlock, and has no Overwrite or Delete. Both are kept inside the save file, so backups keep them. Saving into the slot again starts without a note. - The first time the Saves window opens in the web version, a message says it has fewer slots (once per device).
- If the storage still fills up, saving fails with a message and the Saves window shows Browser storage has run out. Export your saves to keep your progress. until a save works again or one is deleted.
- An import or a backup restore that doesn't fit fails with a message; a restore then puts every slot back as it was.
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.
- The map part is taken at once, the whole screen a moment later (it replaces the first picture in the slot). A save made as the app closes may keep the map-only one.
- Your own layer in the picture: give its root element
data-capture(it must be a direct child of the game screen, as the event and HUD layers are).
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.
| System | Folder |
|---|---|
| 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/ |
| Android | The 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. |
| Browser | localStorage, 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
- The desktop folder name comes from
nameinpackage.json; renaming the game there moves the folder (old saves stay in the old one). - Each save file is plain JSON, so you can copy them in and out by hand.
- Files are written to a
.tmpfile first and then swapped in, so a crash never leaves half a save. - Saves an older version of the app kept in localStorage are moved into the folder on the first start. If a slot is in both places, the newer save is kept.
- Files are written in the background. If a write fails (disk full, no permission) the player gets a message and the Saves window shows a warning until a write works again.
- A file that can't be read is skipped (its slot shows as empty); the other saves still load.
- Desktop: closing the window (X, Alt+F4, Quit) first autosaves (if
appHiddenis on) and waits for the files to be written, 3 seconds at most.
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.
| System | Export | Import |
|---|---|---|
| Desktop | "Save as" dialog (starts in Documents) | "Open" dialog, or drop a file on the Saves window |
| Android | Share sheet: Files, Drive, a chat, … | The system file picker (shows every file type) |
| Browser | A download | File 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.
- Saves: each one is upgraded by the save migrations. If any one can't be used (damaged, or from a newer game), the whole backup is refused and nothing changes. The error names the slot.
- Persistent data is upgraded by the persistent migrations if the backup is older, then replaces this device's. Fields it doesn't have get their empty default. No achievement pop-ups.
- The Saves window always asks first: Replace everything / Cancel.
{
"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.
| What | Upgrade files | Current version |
|---|---|---|
Save files (save/data.ts + engine state) | src/content/save/migrations/vN.ts | Highest N, or 1 |
| Persistent data (read lines, unlocks, achievements) | src/content/save/persistent_migrations/vN.ts | Highest N, or 1 |
| Backup file layout | none (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?
| Change | Migration? |
|---|---|
| New flag, quest, item, map, event, achievement | No. They start at their defaults in old saves. |
New field in data.ts that is fine at its initial value | Yes, a one-liner that adds it (old saves don't have it). |
| Field renamed, moved, removed, or its type changed | Yes. |
| A map, event or item id renamed that saves refer to | Yes, rename it in old saves (engine.map.id, inventory keys…). |
| Before the first release | No. Change data.ts freely; just delete your own test saves. |
Adding v2 (then v3, v4…)
- Change the shape in
save/data.ts(here:hprenamed tohealth). - Create the next file. The first one is
v2.ts; it upgrades a version 1 save to version 2. The next isv3.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 } } } }) - Add an example of a version 1 save to
OLD_SAVESinsrc/content/save.test.ts.pnpm testthen 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: {} } }, ] - Never edit a migration once players have it. Fix mistakes with the next number.
- Loading a version 1 save in a game at version 4 runs
v2,v3,v4in order, thenbeforeLoad. Each step only knows the step before it. - Inside a migration,
datais loosely typed on purpose: it's the old shape. Use??for anything that might be missing. engineis the engine's part (map, position, quests, money…). Change it only for renamed ids.- The same steps upgrade old saves in backups.
- A save from a newer game is refused with a clear message. Damaged files and missing steps are refused too; nothing is overwritten.
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: {} }
})
- Change
PersistentStateand itsempty()defaults instores/persistent.ts. - Add the
vN.tsfile above (first one isv2.ts). - Add an example to
OLD_PERSISTENTinsrc/content/save.test.ts. - 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)
- Your
newGameruns as always. Usegame.save.cycle()there and in events for anything that differs the second time. - Party members are not added for you:
game.party.add('hero')finds the carried level and equipment. Everyone starts rested. - A plain New game starts from nothing; New Game+ stays available.
- In the Saves window, a save from a New Game+ playthrough (
cycle1 or more) has a small NG+ tag in its top left corner, on the same strip colours as the text below. Saves from the first playthrough have none. A slot'scycleis also ingame.save.list().
Data outside the save slots
Kept per device across all saves and new games. Persistent data goes into backups; settings don't.
| What | Where |
|---|---|
| Settings | game/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 over | game/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')
- Kept per device across all saves and new games, in backups, and erased with Erase all data.
- A value added later starts at its value here. A stored value of another kind than its starting value is dropped.
- While a scene plays from Extras → Show all, changes are undone afterwards, like everything else earned there.
Settings
| Setting | |
|---|---|
volume | master, music, sfx, voice (0..1) |
textSpeed | Letters per second; the top of the slider means instant |
autoDelay, skipUnread, skipAfterChoice, skipEffects | Auto-play pause; Skip also skips unread lines; Skip comes back after a choice; fades and animations finish at once while skipping |
fullscreen | Applied on start (browsers: on the first key press) |
screenRatio, cursorAutoHide | Game screen shape; seconds before an idle mouse hides. Choices and defaults: content/config/screen.ts |
language | 'source' or a language folder id |
bindings | The player's own keys/buttons per action |
showDevPanel | Dev 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.