ScriptedValueRegistry
The scriped value registry is an object that may be used by scripts to store persistent values across game environments. Using the scripted value registry, campaign and battle scripts can pass simple messages between one another which is otherwise difficult to achieve. The values stored in the scripted value registry are cleared whenever loading into the frontend, however, unless they've been saved as persistent.
The scriped value registry also provides functions that allow script to save boolean values into the operating system registry, which can be queried later to determine if a particular event has ever occurred, for example.
Loaded in Campaign | |
Loaded in Battle | |
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
The functions in this section can be used to save values into the scripted value registry that may be read by scripts in other environments. The values are not saved into the operating system registry, however, so will be cleared when the game is shut down and restarted.
Values saved with ScriptedValueRegistry:SaveBool
or ScriptedValueRegistry:SaveString
will be cleared if the game loads back into the frontend. Values may be saved as persistent to avoid them being cleared in this way with the functions ScriptedValueRegistry:SavePersistentBool
and ScriptedValueRegistry:SavePersistentString
. These values may be read later with ScriptedValueRegistry:LoadPersistentBool
and ScriptedValueRegistry:LoadPersistentString
.
The internal mapping used for persistent and non-persistent values are different, so a value saved with ScriptedValueRegistry:SavePersistentString
cannot be loaded with ScriptedValueRegistry:LoadString
, for example.
-
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 corresponding to a supplied string name from the scripted value registry. If no value with the supplied name is found then
false
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 corresponding to a supplied string name from the scripted value registry. If no value with the supplied name is found then an empty string is returned.
Parameters:
1
value name
Returns:
valuestring
-
ScriptedValueRegistry:SavePersistentBool(
value namestring
,
valueboolean
)
-
Saves a persistent boolean value with a string name into the scripted value registry. Persistent values are not cleared between game environments.
Parameters:
1
value name
2
value
Returns:
nil
-
ScriptedValueRegistry:LoadPersistentBool(
value namestring
)
-
Returns a persistent boolean value corresponding to a supplied string name from the scripted value registry. If no persistent value with the supplied name is found then
false
is returned.Parameters:
1
value name
Returns:
valueboolean
-
ScriptedValueRegistry:SavePersistentString(
value namestring
,
valuestring
)
-
Saves a persistent string value with a string name into the scripted value registry. Persistent values are not cleared between game environments.
Parameters:
1
value name
2
value
Returns:
nil
-
ScriptedValueRegistry:LoadPersistentString(
value namestring
)
-
Returns a persistent string value corresponding to a supplied string name from the scripted value registry. 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, which is persistent between game loads. 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 corresponding to a supplied string name from the operating system registry. If no value with the supplied name is found then
false
is returned.Parameters:
1
value name
Returns:
valueboolean
-
ScriptedValueRegistry:SaveRegistryString(
value namestring
,
valuestring
)
-
Saves a string value with a string name into the operating system registry.
Parameters:
1
value name
2
value
Returns:
nil
-
ScriptedValueRegistry:LoadRegistryString(
value namestring
)
-
Returns a string value corresponding to a supplied string name from the operating system registry. If no value with the supplied name is found then a blank string is returned.
Parameters:
1
value name
Returns:
valuestring
-
ScriptedValueRegistry:SaveRegistryTimestamp(
timestamp namestring
)
-
Saves a timestamp with the supplied string name into the registry. This can later be looked up with
ScriptedValueRegistry:CompareRegistryTimestamp
which returns the elapsed time in seconds from when the value was saved to when it was later compared.Parameters:
1
timestamp name
Returns:
nil
-
ScriptedValueRegistry:CompareRegistryTimestamp(
timestamp namestring
)
-
Looks up a timestamp saved into the registry with the supplied name, and returns the elapsed time in seconds since that timestamp was last made. This includes time when the game was not running. If no timestamp with the supplied name has previously been saved then
-1
is returned.
Timestamps can be saved by callingScriptedValueRegistry:SaveRegistryTimestamp
.Parameters:
1
timestamp name
Returns:
elapsed secondsnumber