Skip to content

Game flow

What a save game restores (persist) and what is carried across runtime scene changes (carry).

persist

Saves this entity in save games (save_game in Wander, the save_game tool): its whole state or chosen fields, plus its Wander vars. Put it on the player, doors, collectibles, quest givers; leave scenery without it. Spawned entities (spawn() at run time) need spawned: true to be recreated on load.

Field Type Description Values
id string Stable save key ("player", "door_3"). Empty: the entity id, stable for entities placed in a scene. Set it for entities whose id can change (re-created by a script, moved between scenes)
mode string all (name, tags, enabled, parent and every component) | fields (only fields) | vars (Wander vars only) all fields vars
fields string[] mode fields: what to save, as component names or component.field, e.g. ["transform", "light.intensity", "body.velocity"]
vars boolean Also save the entity's Wander vars (hp, inventory, quest state)
spawned boolean Created at run time (spawn): a load recreates it, with its children and saved ids, when it is missing; copies spawned after the save are removed
prefab string Prefab it was spawned from (informational, shown in save_inspect; filled in from the prefab link when empty)
entity_update {"entity": "Crate", "components": {"persist": {}}}
self.persist.id          -- read or write any field

carry

Carries this entity and its children across runtime scene changes (change_scene in Wander, scene_change): a game manager, the player, background music. Its behaviors keep running with their state. If the next scene has an entity with the same carry key, that copy is dropped, so a manager can sit in every level. Not the same as persist, which marks what a save game restores (a player usually has both).

Field Type Description Values
id string Key that identifies the same entity in other scenes ("game_manager"). Empty: the entity's name
spawn boolean Move to the spawn_at entity of a scene change (the player). Without any, entities tagged "player" move
entity_update {"entity": "Crate", "components": {"carry": {}}}
self.carry.id          -- read or write any field