API Reference › Builtin functions › save
function

save

save()

Captures a complete snapshot of the running world in a single call: every spawned model instance and its properties, plus every program-level var. The compiler generates the serialization for you from your declarations, so you never write it by hand. Pair it with load to implement quick-save / quick-load, checkpoints, or deterministic test fixtures. It takes no arguments and writes to the runtime's snapshot slot; calling it again overwrites the previous snapshot.

Example

program QuickSave {
  property Position { column: int = 0, row: int = 0 }
  model Player { Position }

  handler SpawnPlayer phase Start {
    spawn Player { Position { column: 5, row: 5 } }
  }

  handler ReadInput phase Input {
    let pressed = Input.key()
    if pressed == 's' { save() }
    if pressed == 'l' { load() }
  }

  handler DrawWorld phase Render {
    Screen.clear(Color.MidnightBlue)
    Screen.show()
  }
}
← All symbols