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 Campaign
Loaded in Battle Loaded in Battle
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

ScriptedValueRegistry:SaveRegistryString(string value name, string value)

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

Parameters:

1

string

value name

2

string

value

Returns:

  1. nil

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

ScriptedValueRegistry:LoadRegistryString(string value name)

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

string

value name

Returns:

  1. string value

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

ScriptedValueRegistry:SaveRegistryTimestamp(string timestamp name)

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

string

timestamp name

Returns:

  1. nil

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

ScriptedValueRegistry:CompareRegistryTimestamp(string timestamp name)

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 calling ScriptedValueRegistry:SaveRegistryTimestamp.

Parameters:

1

string

timestamp name

Returns:

  1. number elapsed seconds

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

Last updated 12/08/2022 11:56:58