StorageOptions
ClassSettings for saving values in a MultiplayerSession.
- Available on all platforms
Index
Properties
Methods
Example
var options = StorageOptions.create();
options.scope = StorageScope.Session;
// Get a persisted value stored with specified scope
function setStoredValue(key, value, op) {
script.session.setStoredValue(key, value, op,
function onSuccess() {
screenLog("Value [" + key + "] was persisted in scope! " + op.scope);
},
function handleError(code, description) {
screenLog("Error code: " + code + " description: " + description);
});
}
// Get value stored with specified scope
function getStoredValue(key, scope) {
script.session.getStoredValue(key, scope,
function onSuccess(key, value) {
screenLog("Value of " + key + " is: " + value);
},
function handleError(code, description) {
screenLog("Error code: " + code + " description: " + description);
});
}
// Delete value stored with specified scope
function deleteStoredValue(key, scope) {
// Delete a persisted value from the collection
script.session.deleteStoredValue(key, scope,
function onSuccess() {
screenLog("Value " + key + " was deleted");
},
function handleError(code, description) {
screenLog("Error code: " + code + " description: " + description);
});
}
function listStoredValues(scope) {
var pageNumber = 0;
var limit = 10; //constant
function handleError(code, description) {
screenLog("Error code: " + code + " description: " + description);
};
function onListRetrieved(results, cursor) {
screenLog(" page " + (pageNumber++) + " contains " + results.length + " results " + "cursor " + cursor);
// Results are returned as a list of [key, value] tuples
for (var i = 0; i < results.length; ++i) {
const key = results[i][0];
const value = results[i][1];
screenLog(" - key: " + key + " value: " + value);
}
// Request the next page of results
if (results.length == limit) {
script.session.listStoredValues(options.scope, cursor, onListRetrieved, handleError);
}
}
script.session.listStoredValues(scope, "", onListRetrieved, handleError);
}
Extends
Properties
scope
scope:
StorageScope
The Storage Scope to set, get, or delete values from.
Since
Lens Scripting Version 148
Methods
create()
staticcreate():StorageOptions
Create a new StorageOptions object.
Returns
StorageOptions
Since
Lens Scripting Version 148
getTypeName()
staticgetTypeName():TypeName<StorageOptions>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<StorageOptions>
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean