sm.storage
Associated object type: Storage
Storage is used for saving and loading any Lua data into the world's database.
This allows for data to be retrieved after closing and reloading the world.
Storage can only be used on the server.
Storage allows for data to be saved immediately into the world's database.
This is a very slow process and should be done as sparsely as possible.
If you have data that is shared globally and updated often, consider using global variables instead.
Ideally, storage should only be used to save data upon closing the world, or when saving a creation on the Lift.
Functions
load
sm.storage.load( key )
Loads Lua data stored with a given key. The key can be any Lua object.
If no data is stored with the given key, this returns nil.
When used on the client, this function will return data saved with saveAndSync
Arguments:key
[ any ]: The key.
- [ any ]: The stored data.
save
sm.storage.save( key, data )
Server-Only
Saves any Lua object with a given key. The key can be any lua object.
The data will remain stored after closing the world, and is retrieved using load, provided the same key.
The data is stored globally within the current mod. As of such, keys will not collide with external mods and scripts.
key
[ any ]: The key to store the data with.data
[ any ]: The data to be stored.
saveAndSync
sm.storage.saveAndSync( key, data )
Server-Only
Saves any Lua object with a given key and synchronizes it to all clients. The key can be any lua object.
The data will remain stored after closing the world, and is retrieved using load, provided the same key.
The data is stored globally within the current mod. As of such, keys will not collide with external mods and scripts.
key
[ any ]: The key to store the data with.data
[ any ]: The data to be stored.