Skip to content

Search

Documentation

save

Save games: a table in, a table out, stored per user. [save] version stamps each file; [save] migrate_script names the script whose migrate_save(version…

On this page

Save games: a table in, a table out, stored per user. [save] version stamps each file; [save] migrate_script names the script whose migrate_save(version, data) upgrades older ones.

6 functions, 0 constants. Scripts reach it as save::.

Functions

Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.

function acts on what it does
directory() -> string — The directory slots are kept in, not created until something is written.
read(string) -> any — The table in a slot, brought forward to this build's version; nil when the slot was never written. An error when the file was written by a newer build, or when it needs a migration the project declares no script for.
remove(string) — Delete a slot. Not an error when it was not there.
slots() -> [str] — Every slot that has been written, in name order.
version() -> int — The save version this build writes, from [save] version.
write(string, any) — Write a table to a named slot, stamped with the project's save version. Written beside the target and renamed over it, so a crash mid-save cannot destroy the last one. A script hears this and every remove with events::listen(this.node, "saved"), as on_saved(count).

Are you sure?