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 battle
Loaded in Campaign loaded in campaign
Loaded in Frontend loaded in frontend
Back to top

Creation

ScriptedValueRegistry:new()

Creates and returns a handle to the scripted value registry.

Returns:

  1. ScriptedValueRegistry svr

defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1196

Back to top

Usage

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
Back to top

Game Session Registry

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(string value name, boolean value)

Saves a boolean value with a string name into the scripted value registry.

Parameters:

1

string

value name

2

boolean

value

Returns:

  1. nil

defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1236

ScriptedValueRegistry:LoadBool(string value name)

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

string

value name

Returns:

  1. boolean value

defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1279

ScriptedValueRegistry:SaveString(string value name, string value)

Saves a string value with a string name into the scripted value registry.

Parameters:

1

string

value name

2

string

value

Returns:

  1. nil

defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1319

ScriptedValueRegistry:LoadString(string value name)

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

string

value name

Returns:

  1. string value

defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1359

ScriptedValueRegistry:SavePersistentBool(string value name, boolean value)

Saves a persistent boolean value with a string name into the scripted value registry. Persistent values are not cleared between game environments.

Parameters:

1

string

value name

2

boolean

value

Returns:

  1. nil

defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1399

ScriptedValueRegistry:LoadPersistentBool(string value name)

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

string

value name

Returns:

  1. boolean value

defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1442

ScriptedValueRegistry:SavePersistentString(string value name, string value)

Saves a persistent string value with a string name into the scripted value registry. Persistent values are not cleared between game environments.

Parameters:

1

string

value name

2

string

value

Returns:

  1. nil

defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1482

ScriptedValueRegistry:LoadPersistentString(string value name)

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

string

value name

Returns:

  1. string value

defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1522

Back to top

Operating System Registry

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(string value name, boolean value)

Saves a boolean value with a string name into the operating system registry.

Parameters:

1

string

value name

2

boolean

value

Returns:

  1. nil

defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1575

ScriptedValueRegistry:LoadRegistryBool(string value name)

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

string

value name

Returns:

  1. boolean value

defined in ../../common/EmpireUtility/Source/EmpireLuaEnv.cpp, line 1611

Last updated 25/08/2021 12:07:50