Kanzi  3.9.9
Kanzi Engine C++ API
kanzi::LuaInstance Class Reference

Loads and runs Lua scripts. More...

#include <kanzi/lua/lua_instance.hpp>

Public Member Functions

bool loadScript (string_view scriptName, string_view code)
 Loads a Lua script and assigns a name to the script. More...
 
bool loadScript (BinaryResource &resource)
 Loads a binary resource as a Lua script. More...
 
void run (string_view scriptName)
 Runs a previously loaded Lua script with a matching name. More...
 
void run (string_view scriptName, NodeSharedPtr contextNode)
 Runs a previously loaded Lua script with a matching name. More...
 
void run (const BinaryResource &resource)
 Runs a previously loaded resource loaded as a Lua script. More...
 
void run (const BinaryResource &resource, NodeSharedPtr contextNode)
 Runs a previously loaded resource loaded as a Lua script. More...
 
 ~LuaInstance ()
 Destructor. More...
 

Static Public Attributes

static PropertyType< int > LuaInstanceIDProperty
 Set to binary resources of scripts that are loaded into the Lua instance. More...
 

Friends

class LuaModule
 Friend classes. More...
 

Detailed Description

Loads and runs Lua scripts.

Use the LuaModule to initialize, retrieve, and free the LuaInstance.

See also
LuaModule
Since
Kanzi 3.9.9

Constructor & Destructor Documentation

kanzi::LuaInstance::~LuaInstance ( )

Destructor.

Member Function Documentation

void kanzi::LuaInstance::run ( string_view  scriptName)

Runs a previously loaded Lua script with a matching name.

Parameters
scriptNameName of the script to be run. If nullopt, runs the latest loaded Lua script.
void kanzi::LuaInstance::run ( string_view  scriptName,
NodeSharedPtr  contextNode 
)

Runs a previously loaded Lua script with a matching name.

Parameters
scriptNameName of the script to be run.
contextNodeThe context node attached to the script.
void kanzi::LuaInstance::run ( const BinaryResource resource)

Runs a previously loaded resource loaded as a Lua script.

Parameters
resourceThe binary resource that contains the Lua script to run.
void kanzi::LuaInstance::run ( const BinaryResource resource,
NodeSharedPtr  contextNode 
)

Runs a previously loaded resource loaded as a Lua script.

Parameters
resourceThe binary resource that contains the Lua script to run.
contextNodeThe context node attached to the script.
bool kanzi::LuaInstance::loadScript ( string_view  scriptName,
string_view  code 
)

Loads a Lua script and assigns a name to the script.

When you assign a name that is already in use by another script, the script replaces the previously loaded script.

Parameters
codeLua script to load.
scriptNameName of the script.
Returns
True if the script is loaded.
bool kanzi::LuaInstance::loadScript ( BinaryResource resource)

Loads a binary resource as a Lua script.

The script does not load the script if is already loaded. The name of the script is the resource URL.

Parameters
resourceThe binary resource that contains the Lua script.
Returns
True if the binary resource is loaded as a Lua script.

Friends And Related Function Documentation

friend class LuaModule
friend

Friend classes.

Member Data Documentation

PropertyType<int> kanzi::LuaInstance::LuaInstanceIDProperty
static

Set to binary resources of scripts that are loaded into the Lua instance.


The documentation for this class was generated from the following file: