Skip to content

Search

Documentation

save module

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

Σε αυτή τη σελίδα

Save games: a table in, a table out, stored per user. [save] version stamps each file; [save] migrate 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() — The directory slots are kept in, not created until something is written.
read(slot: string) — 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(slot: string) — Delete a slot. Not an error when it was not there.
slots() — Every slot that has been written, in name order.
version() — The save version this build writes, from [save] version.
write(slot: string, data: 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.