xhookLua
Game

db

Per-script persistent key-value store in scripts\data\<script>\db.json; survives reloads and restarts.

Functions

db.get

db.get(key [, default]) -> any
NameTypeDescription
keystring
defaultoptionalanyReturned when the key is unset. Default nil.

Reads a stored value from memory.

Returns stored value, or default

  • Number keys may come back as strings; use string keys.
  • A corrupt db.json loads as an empty store.

db.set

db.set(key, value)
NameTypeDescription
keystring
valueanyBool, number, string, table; nil removes.

Stores a value and rewrites db.json.

  • Rewrites the whole file, so don't call it every frame.
  • Functions and userdata become null and are lost.

db.delete

db.delete(key)
NameType
keystring

Removes a key and rewrites db.json.

db.all

db.all() -> table

Whole store as a key to value table.

Returns the live store, not a copy

Edits save only on the next db.set or db.delete.

db ยท Lua API ยท xhook