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 Battle | |
Loaded in Campaign | |
Loaded in Frontend |
-
ScriptedValueRegistry:new()
-
Creates and returns a handle to the scripted value registry.
Returns:
defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1196
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
defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1236
-
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
defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1279
-
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
defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1319
-
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
defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1359
-
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
defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1399
-
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
defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1442
-
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
defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1482
-
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
defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1522
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
defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1575
-
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
defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1611