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| Name | Type | Description |
|---|---|---|
| key | string | |
| defaultoptional | any | Returned 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)| Name | Type | Description |
|---|---|---|
| key | string | |
| value | any | Bool, 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)| Name | Type |
|---|---|
| key | string |
Removes a key and rewrites db.json.
db.all
db.all() -> tableWhole 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.