ScriptedValueRegistry
The scriped value registry is an object that may be used by scripts to store persistent values across game environments. It may be used by campaign and battle scripts to pass simple messages between one another, which is otherwise difficult to achieve.
The scripted value registry provides three methods of storing values. Values saved using game session functions are cleared when loading into a new campaign, or when loading back into the frontend. Values saved using persistent functions are not cleared until the game shuts down. Finally, values saved into the operating system registry are never cleared.
The internal mapping for each set of values is different, so a value saved using ScriptedValueRegistry:SaveBool
cannot be loaded using ScriptedValueRegistry:LoadPersistentBool
, for example.
Loaded in Battle | |
Loaded in Campaign | |
Loaded in Frontend |
-
ScriptedValueRegistry:new()
-
Creates and returns a handle to the scripted value registry.
Returns:
Once a scripted value registry has been created, functions may be called on it in the following form.
Example - Specification:
<object_name>:<function_name>(<args>)
Example - Creation and Usage:
svr = ScriptedValueRegistry:new()
svr:SaveBool("test_value", true) -- calling a function on the object once created
Values saved using these functions will be cleared whenever loading into a new campaign, or whenever the frontend is loaded.
-
ScriptedValueRegistry:SaveBool(
value namestring
,
valueboolean
)
-
Saves a boolean value with a string name into the scripted value registry.
Parameters:
1
value name
2
value
Returns:
nil
-
ScriptedValueRegistry:LoadBool(
value namestring
)
-
Returns a boolean value that was previously stored with
ScriptedValueRegistry:SaveBool
, by name. If no value with the supplied name is found thenfalse
is returned.Parameters:
1
value name
Returns:
valueboolean
-
ScriptedValueRegistry:SaveString(
value namestring
,
valuestring
)
-
Saves a string value with a string name into the scripted value registry.
Parameters:
1
value name
2
value
Returns:
nil
-
ScriptedValueRegistry:LoadString(
value namestring
)
-
Returns a string value previously stored with
ScriptedValueRegistry:SaveString
, by name. If no value with the supplied name is found then an empty string is returned.Parameters:
1
value name
Returns:
valuestring
Values saved using these functions will only be cleared when the game is shut down and reloaded.
-
ScriptedValueRegistry:SavePersistentBool(
value namestring
,
valueboolean
)
-
Saves a boolean value with a string name into the persistent registry.
Parameters:
1
value name
2
value
Returns:
nil
-
ScriptedValueRegistry:LoadPersistentBool(
value namestring
)
-
Returns a persistent boolean value previously stored with
ScriptedValueRegistry:SavePersistentBool
, by name. If no persistent value with the supplied name is found thenfalse
is returned.Parameters:
1
value name
Returns:
valueboolean
-
ScriptedValueRegistry:SavePersistentString(
value namestring
,
valuestring
)
-
Saves a string value with a string name into the persistent registry.
Parameters:
1
value name
2
value
Returns:
nil
-
ScriptedValueRegistry:LoadPersistentString(
value namestring
)
-
Returns a persistent string value previously stored with
ScriptedValueRegistry:SavePersistentString
, by name. If no persistent value with the supplied name is found then an empty string is returned.Parameters:
1
value name
Returns:
valuestring
The functions in this section can be used to store and retrieve values from the operating system registry. Values saved here remain persistent between reloads of the game. No path within the registry may be specified.
-
ScriptedValueRegistry:SaveRegistryBool(
value namestring
,
valueboolean
)
-
Saves a boolean value with a string name into the operating system registry.
Parameters:
1
value name
2
value
Returns:
nil
-
ScriptedValueRegistry:LoadRegistryBool(
value namestring
)
-
Returns a boolean value previously stored with
ScriptedValueRegistry:SaveRegistryBool
, by name. If no persistent value with the supplied name is found thenfalse
is returned.Parameters:
1
value name
Returns:
valueboolean