SixL client API / system / StorageMp
Interface: StorageMp
The client's storage: a data object kept on this computer between sessions (data), and one that lasts only for this session (sessionData).
Remarks
data is loaded before the scripts start. It is saved by flush() and when the client exits; changes made by the scripts are kept even without a flush(). Values must be JSON-serialisable: an object that cannot be converted is not saved.
Example
mp.storage.data.lastServer = 'main';
mp.storage.flush();
Properties
data
data: object
The stored data: a plain object. Kept between sessions.
Index Signature
[key: string]: unknown
Example
mp.storage.data.volume = 0.5;
sessionData
sessionData: object
The data of this session only. It is not kept when the client exits.
Index Signature
[key: string]: unknown
Example
mp.storage.sessionData.visited = true;
Methods
flush()
flush(): void
Saves data to this computer now, without waiting for the exit.
Returns
void
Remarks
The save is sent to the core; an object that cannot be converted to JSON is not saved, and the error is logged.
Example
mp.storage.flush();