State

A State handle accesses persistent values belonging to one named subsystem on one object. Create a handle with Object:state.

Namespaces and keys are exact and case-sensitive. They begin with an ASCII letter and may contain letters, digits, _, -, ., and /; keys are at most 255 bytes. Values retain their Lua scalar type across reloads and restarts. Supported values are strings, booleans, integers, and finite numbers. Empty strings are values; nil deletes a value.

Every callback has an implicit transaction. Reads observe earlier writes from that callback, including writes to multiple objects. A successful callback commits them together; a Lua error or memory-limit error discards them. The configured per-value, per-object entry, and per-object byte limits are enforced before data leaves the Lua VM.

Methods

MethodDescription
State:getGets a value or a caller-supplied default.
State:hasTests whether a key exists.
State:setSets or deletes a value.
State:deleteDeletes a value and reports whether it existed.
State:keysLists keys in sorted order.
State:entriesLists key/value records in sorted order.
State:get_manyGets all present keys from a requested set.
State:set_manyApplies a table of updates.

Notes

Do not attempt to hold a transaction across flow steps or other player input; persist an explicit reservation instead.

See Also