Saving Games Across Modules (0.6)
中文 · User guide
This page is maintained by hand; the Chinese documentation is authoritative. Check that your SDK contains the APIs described here before using a dev feature.
Player saves combine gameplay domains using JSON text, strict validation and atomic publication. There is no separate universal save module.
Principles
- Each mutable fact has one authoritative owner, such as
GameState,Tracker, a bag or a battle. Serialize that state. - Validate the entire candidate before publishing it. If a participant fails, all participants keep their original state.
- Item, quest and ability definitions belong to content, not the player's save. Load matching
contentVersiondefinitions before restoring. - Write to disk with
fs.writeTextAtomicand check success.fsis the startup filesystem instance. Validate before restoring and try a backup if the primary save is invalid.
Choose the save path
- RPG:
eve.RPGSaveSession()coordinatesGameState,Tracker, a character orRPGParty,BagandEquipmentSet. See rpg-classic and the RPG guide (Chinese). - Inventory only:
eve.InventorySaveSession()coordinatesBagandEquipmentSet. See inventory (Chinese). - Tactics: battle snapshot and optional command log preserve the tactics
Battle. See tactics example and guide (Chinese).
examples/combat-arena is a deterministic simulation demonstration, not a cross-session save acceptance example. Connect HP and cooldowns to RPG or your own authoritative state before persisting them.
RPG: the recommended path
These are integration fragments: gameState, tracker, party, bag, equipment, actor and json come from your game. Handle each failure before proceeding; do not restore a candidate that validation rejected.
The Chinese RPG guide covers content versions, ID renames, appended quest migrations and single-character-to-party migration.
Tactics: snapshot and optional replay log
The log must be anchored to the snapshot's baseline. HP or cooldowns owned by ECS/RPG are not automatically included in a tactics snapshot. Save them separately and restore in a defined order. A single transaction combining board and RPG state is a 0.7 roadmap goal; 0.6 callers coordinate it explicitly.
Save slots and backups
Check the return contract of file operations. Paths must stay inside the configured save directory. WebGPU currently cannot provide the same atomic replacement guarantee and reports failure; see files and hot reload.
rpg-classic rotates three slot files and .backup.json files, and lists only slots passing validateSnapshotJson on the title screen.
Avoid these mistakes
- Using engine/DevTools debug snapshots as the player-save format.
- Mutating authoritative containers to test a restore before validation succeeds.
- Saving rebuildable equipment modifiers, render caches or transient event queues.
- Assuming a tactics snapshot also owns RPG state.
See RPG, inventory, tactics and the 0.6 closeout checklist for domain-specific details; these pages are currently in Chinese.