Skip to main content
reskate.storage keeps values between game launches: settings, scores, saved spots. Every function needs the storage permission. Storage is a set of keys, each holding a value that can be turned into JSON: nil, booleans, numbers, strings, and tables of those (a list, or a table with string keys). It is not shared with other plugins or other players.

Keys and sizes

  • A key is a string of 1 to 128 characters.
  • The whole store, written as compact JSON, is at most 1 MB. A set or add that would make it larger raises an error (“storage is full”), and the key keeps the value it had.
  • A value has the same rules as reskate.json.encode: tables nested at most 32 deep, no functions, vectors or buffers, no NaN or infinity.

Where and when it is saved

ReSkate saves a plugin’s storage at most every 2 seconds while it changes, and once more when the plugin unloads or stops. It is written to a temporary file first, so a crash mid-save leaves the last good file. <folder> is the plugin’s mod folder name, and each copy’s storage folder is its reskate.id: <folder>@server for the server copy on a lobby’s host, so it never shares storage with the client copy beside it. A renamed mod folder starts with empty storage. The file is saved as compact JSON, the same way the 1 MB quota measures it. When it cannot be read (it is too large, or broken, or not a JSON object), it is renamed storage.json.bad, a warning is logged, and the plugin starts with empty storage. The next save does not overwrite the .bad file.

reskate.storage.get(key)

The value a key holds.
string
required
1 to 128 characters.
any
A copy of the value, or nil when the key holds nothing. Changing a table you got changes nothing in storage until you set it again.

reskate.storage.set(key, value)

Sets a key’s value, or removes the key.
string
required
1 to 128 characters.
any
required
A value that can be turned into JSON. nil removes the key.

reskate.storage.add(key, by)

Adds a number to a key’s number and returns the new value. A key that holds nothing counts from 0.
string
required
1 to 128 characters.
number
default:"1"
A finite number, negative to take away.
number
The key’s value after adding.

reskate.storage.keys()

Every key that holds a value.
table
A list of strings, sorted.
Needs storage. Raises an error for a key that is empty or longer than 128 characters, a value that cannot be turned into JSON, add on a key that holds something other than a number, a non-finite by, and a store that would grow past 1 MB.