Storage¶
The Storage
global provides access to the script's associated Persistence object. The Persistence object is where your script can store simple forms of data on a user's computer.
Bins¶
We provide two "storage bins:" The Public
bin and the Private
bin. Each bin is a property of the Storage global and are almost identical in terms of API. Each bin has a set amount of data that they can store, as well, to prevent malicious scripts from filling up the user's hard drive.
Public¶
The Public bin is accessible as Storage.Public
. This bin's corresponding file on disk is user-editable, as it is stored as clear-text JSON. This file is intended to be used for things the user may need to edit, such as configuration or tuning values.
Properties¶
Name | Type | Notes |
---|---|---|
BytesAllowed |
int |
How many bytes are allowed for this storage bin, in total. Currently set to Does not include data outside of your control that we add during the serialization process, such as encryption stuff, headers, section data, etc. |
CurrentSize |
int |
Current reported size of this storage bin, in bytes. Does not include data outside of your control that we add during the serialization process, such as encryption stuff, headers, section data, etc. |
IsEncrypted |
bool |
Whether this storage bin is encrypted on disk. Always false for Public bins. |
Path |
string |
Path of the file on disk. |
Methods¶
Name | Notes |
---|---|
GetBoolean(string key) : bool? |
Get the value of a key as a boolean , or nil if the key is nil or not present. |
GetNumber(string key) : number? |
Get the value of a key as a number , or nil if the key is nil or missing. |
GetString(string key) : string? |
Get the value of a key as a string , or nil if the key is nil or missing. |
GetTable(string key) : table? |
Get the value of a key as a table , or nil if the key is nil or missing. |
HasValue(string key) : bool |
Determine if the given named key is present in the underlying table . |
Load() : void |
Loads data from disk, if present. |
Save() : void |
If anything has changed (if the storage is marked dirty), save to disk. A successful save will clear dirtiness. |
SetBoolean(string key, bool? value) : void |
Set the value of a key to a You will need to call |
SetNumber(string key, number? value) : void |
Set the value of a key to a You will need to call |
SetString(string key, string? value) : void |
Set the value of a key to a You will need to call |
SetTable(string key, table? value) : void |
Set the value of a key to a IMPORTANT: Any values in the provided table or subtables that are not You will need to call |
Private¶
The Private bin is accessible as Storage.Private
. This bin's corresponding file on disk is encrypted and stored as a binary format, as it is intended to be used for storing deliberately opaque data, such as a user's score in a game, character levels, et cetera.
Properties¶
Name | Type | Notes |
---|---|---|
BytesAllowed |
int |
How many bytes are allowed for this storage bin, in total. Currently set to Does not include data outside of your control that we add during the serialization process, such as encryption stuff, headers, section data, etc. |
CurrentSize |
int |
Current reported size of this storage bin, in bytes. Does not include data outside of your control that we add during the serialization process, such as encryption stuff, headers, section data, etc. |
IsEncrypted |
bool |
Whether this storage bin is encrypted on disk. Always false for Private bins. |
Path |
string |
Path of the file on disk. |
Methods¶
Name | Notes |
---|---|
GetBoolean(string key) : bool? |
Get the value of a key as a boolean , or nil if the key is nil or not present. |
GetNumber(string key) : number? |
Get the value of a key as a number , or nil if the key is nil or missing. |
GetString(string key) : string? |
Get the value of a key as a string , or nil if the key is nil or missing. |
GetTable(string key) : table? |
Get the value of a key as a table , or nil if the key is nil or missing. |
HasValue(string key) : bool |
Determine if the given named key is present in the underlying table . |
Load() : void |
Loads data from disk, if present. |
Save() : void |
If anything has changed (if the storage is marked dirty), save to disk. A successful save will clear dirtiness. |
SetBoolean(string key, bool? value) : void |
Set the value of a key to a You will need to call |
SetNumber(string key, number? value) : void |
Set the value of a key to a You will need to call |
SetString(string key, string? value) : void |
Set the value of a key to a You will need to call |
SetTable(string key, table? value) : void |
Set the value of a key to a IMPORTANT: Any values in the provided table or subtables that are not You will need to call |