Skip to content
AEOWUN
Docs Menu

Save data

Look up save data calls and properties.

save.get(key)

Read a saved value.

Arguments

key: string.

Returns

number, bool, string, or nil when missing.

Works with

The current project save slot.

Missing values and errors

A missing key returns nil. Wrong argument counts or types report an error.

One default slot is supported. Set and remove stage changes; only commit writes them. Save data does not change the authored project.

debug.log(save.get("visits"))

save.set(key, value [, default])

Stage a save value in memory.

Arguments

String key, a number, boolean, or string value, and an optional compatible default value.

Returns

nil.

Works with

The current project save slot.

Missing values and errors

Only number, bool, and string values are supported. Wrong argument counts or types report an error.

One default slot is supported. Set and remove stage changes; only commit writes them. Save data does not change the authored project.

Registered defaults [BETA]

The optional third argument supplies an initial default, which save.reset() can restore.

save.set("visits", 1)
save.commit()

save.has(key)

Check whether a save key exists.

Arguments

key: string.

Returns

bool.

Works with

The current project save slot.

Missing values and errors

A missing key returns false. Wrong argument counts or types report an error.

One default slot is supported. Set and remove stage changes; only commit writes them. Save data does not change the authored project.

debug.log(save.has("visits"))

save.remove(key)

Stage removal of a save key.

Arguments

key: string.

Returns

Whether a value was removed.

Works with

The current project save slot.

Missing values and errors

A missing key returns false. Wrong argument counts or types report an error.

One default slot is supported. Set and remove stage changes; only commit writes them. Save data does not change the authored project.

save.remove("visits")
save.commit()

save.commit()

Write staged save changes to disk.

Arguments

No arguments.

Returns

nil on success.

Works with

The current project save slot.

Missing values and errors

Disk failures and unsupported newer save formats report an error. Wrong argument counts or types report an error.

One default slot is supported. Set and remove stage changes; only commit writes them. Save data does not change the authored project.

save.set("tutorial_complete", true)
save.commit()

save.reset([key]) [BETA]

Restore saved values to registered defaults.

Arguments

Optional string key; omit to reset all values.

Returns

nil.

Works with

Current project save slot.

Missing values and errors

Does not rebuild the authored game; commit to persist the reset.

save.reset()

save.restart([key]) [BETA]

Restart the current game or remove one save key.

Arguments

Omit key to restart Play state; a string key removes and commits it.

Returns

nil.

Works with

Current project save slot.

Missing values and errors

Restarting changes the active game state.

save.restart()

save.get_default(key) [BETA]

Read the registered default value of a save key.

Arguments

String key.

Returns

Supported scalar or nil if missing.

Works with

Current project save slot.

Missing values and errors

Missing keys return nil.

const initial = save.get_default("score")