HolyLib Wiki

LuaInterface

LuaInterface

This class represents a completely separate Lua interface (its own Lua state), created with luathreads.CreateInterface.
It can run its own code on a separate thread, independently from the main gamemode's Lua state.

Unlike most other HolyLib classes, this object is not automatically garbage collected. It's destroyed when HolyLib (or the Lua state that created it) shuts down.

Metatable function Description
__tostring Returns a formated string of the LuaInterface -> LuaInterface [name]
__index Used to find the functions on the metatable and access saved variables
__newindex Used to allow one to save variables on the object

Methods

boolean LuaInterface:CanThink( )
Returns whether this interface currently has its own dedicated thread running. (See LuaInterface:EnableThinking)
LuaInterface:EnableThinking( boolean enable )
Enables or disables this interface's own dedicated thread.
While enabled, the interface will continuously run its queued tasks on its own thread, instead of needing LuaInterface:RunTasks to be called manually.
string LuaInterface:GetName( )
Returns the name of this interface. (See LuaInterface:SetName)
table LuaInterface:GetTable( )
Returns the lua table used by newindex and index
boolean LuaInterface:IsValid( )
Returns weather this object is valid or not.
LuaInterface:RunString( string code )
Queues the given code to be run inside this interface.
The code only actually runs once this interface's tasks are executed, either by its own thread (See LuaInterface:EnableThinking) or thru LuaInterface:RunTasks.
LuaInterface:RunTasks()
Queues this interface's pending tasks to run once on HolyLib's holylib_luathreads_threadpool thread pool.
Does nothing if the interface already has its own dedicated thread running. (See LuaInterface:EnableThinking)
LuaInterface:SetName( string name )
Sets the name of this interface, which can later be used with luathreads.FindInterface to find it again.