Available in: Interface Scripts Client Entity Scripts

The Settings API provides a facility to store and retrieve values that persist between Interface runs.


getValue(key, defaultValueopt) → {string|number|boolean|object}
Retrieve the value from a named setting.
Name Type Attributes Default Description
key string The name of the setting.
defaultValue string | number | boolean | object <optional>
"" The value to return if the setting doesn't exist.
The value stored in the named setting if it exists, otherwise the defaultValue.
Type: string | number | boolean | object

Retrieve non-existent setting values.

var value1 = Settings.getValue("Script Example/Nonexistent Key");
print("Value: " + (typeof value1) + " " + JSON.stringify(value1));  // string ""

var value2 = Settings.getValue("Script Example/Nonexistent Key", true);
print("Value: " + (typeof value2) + " " + JSON.stringify(value2));  // boolean true
setValue(key, value)
Store a value in a named setting. If the setting already exists its value is overwritten, otherwise a new setting is created. If the value is set to null or undefined, the setting is deleted.
Name Type Description
key string The name of the setting. Be sure to use a unique name if creating a new setting.
value string | number | boolean | object | undefined The value to store in the setting. If null or undefined is specified, the setting is deleted.

Store and retrieve an object value.

Settings.setValue("Script Example/My Key", { x: 0, y: 10, z: 0 });

var value = Settings.getValue("Script Example/My Key");
print("Value: " + (typeof value) + " " + JSON.stringify(value));  // object {"x":0,"y":10,"z":0}