Leviathan  0.8.0.0
Leviathan game engine
NamedVars

Accessing values

Single values (nonlist values) can be accessed with GetSingleValueByName

ScriptSafeVariableBlock@ var = vars.GetSingleValueByName("PlayerName");
See also
Leviathan::NamedVars::GetScriptCompatibleValue

Leviathan::ScriptSafeVariableBlock can then be used to construct values of actual types.

string name = string(var);
int val = int(var);
int8 initial = int8(var);

Adding values

To add values first create a ScriptSafeVariableBlock.

ScriptSafeVariableBlock@ block = ScriptSafeVariableBlock("PlayerName", "Boost");
See also
Variable blocks in scripts (ScriptSafeVariableBlock)

And then add it to the the Leviathan::NamedVars using AddValue. If a variable with the name was already present it will be deleted before adding the new value.

Note
The value will be deep copied and thus changing the ScriptSafeVariableBlock won't affect the added value.
bool succeeded = vars.AddValue(block);
See also
Leviathan::NamedVars::AddScriptCompatibleValue

Variable blocks in scripts (ScriptSafeVariableBlock)

Todo:
This needs redoing

An AngelScript safe version of Leviathan::NamedVariableBlock

First parameter is the name and the second is the value. Supported types are: string, int, float, double, int8, bool.

ScriptSafeVariableBlock@ var = ScriptSafeVariableBlock("My value!", 2.5f);

Getting primitive values

Getting primite types works by casting to the primite type like in these examples.

ScriptSafeVariableBlock@ var;
string name = string(var);
int val = int(var);
int8 initial = int8(var);