uLua v2.2.0
A Lua Modding Framework for Unity.
uLua.LuaClass Class Reference

Class structure which establishes a Lua object framework. For internal use. More...

Public Member Functions

 LuaClass (string Name, LuaMonoBehaviour Context=null)
 Public constructor. More...
 
void Expose ()
 Used to raise a flag when an object is exposed to Lua. More...
 
void InvokeLua (string FunctionName, params object[] args)
 Invokes a Lua callback function. More...
 
void Register (string FunctionName, string Code="", string args="")
 Registers a Lua callback function. This method is available in Lua. More...
 

Properties

DynValue this[DynValue Key] [get, set]
 Returns a Lua value indexed by the DynValue Key. More...
 
DynValue this[string Key] [get, set]
 Returns a Lua value indexed by the string key. More...
 
LuaMonoBehaviour Context [get, set]
 Used to access/set the context of an object. More...
 
string Handle [get]
 Used to access the unique Handle of a Lua object. More...
 
bool IsExposed [get]
 Used to track if an object has been exposed to Lua. More...
 
string Name [get, protected set]
 Used to access the name of an object. More...
 
- Properties inherited from uLua.ILuaObject
DynValue this[DynValue Key] [get, set]
 Returns a Lua value indexed by the DynValue Key. More...
 
DynValue this[string Key] [get, set]
 Returns a Lua value indexed by the string key. More...
 
LuaMonoBehaviour Context [get, set]
 Used to access/set the context of an object. More...
 
string Handle [get]
 Used to access the unique Handle of a Lua object. More...
 
bool IsExposed [get]
 Used to track if an object has been exposed to Lua. More...
 
string Name [get]
 Used to access the name of an object. More...
 

Detailed Description

Class structure which establishes a Lua object framework. For internal use.

Instances of this class can be exposed to Lua by calling uLua.API.Expose(). All public members of derived classes will be exposed to Lua. Prior to exposing an object of type uLua.LuaClass, the derived type T must be registered to Lua by calling uLua.API.RegisterIndexedType().

Constructor & Destructor Documentation

◆ LuaClass()

uLua.LuaClass.LuaClass ( string  Name,
LuaMonoBehaviour  Context = null 
)
inline

Public constructor.

Parameters
NameSets the name of the object exposed to Lua.
ContextSets the context of the object exposed to Lua.

Member Function Documentation

◆ Expose()

void uLua.LuaClass.Expose ( )
inline

Used to raise a flag when an object is exposed to Lua.

The property IsExposed can be used to check if this method has been called. The IsExposed flag cannot be reset.

Implements uLua.ILuaObject.

◆ InvokeLua()

void uLua.LuaClass.InvokeLua ( string  FunctionName,
params object[]  args 
)
inline

Invokes a Lua callback function.

The callback function must be implemented in a Lua script as a member of this object. Alternatively, you can register a callback function by explicitly calling uLua.LuaMonoBehaviour.Register() with the relevant Lua code.

Parameters
FunctionNameThe name of the callback function to be called.
args(Optional) Parameters for the callback function.

◆ Register()

void uLua.LuaClass.Register ( string  FunctionName,
string  Code = "",
string  args = "" 
)
inline

Registers a Lua callback function. This method is available in Lua.

Used to register a callback function by providing the relevant Lua code.

Parameters
FunctionNameThe name of the callback function to be registered.
Code(Optional) The body of the function to be registered in Lua. If omitted, an empty function with the specified name is defined.
args(Optional) Parameters for the callback function. Must be separated by comma as they would be in a Lua function definition, e.g. 'arg1,arg2'.

Property Documentation

◆ Context

LuaMonoBehaviour uLua.LuaClass.Context
getset

Used to access/set the context of an object.

The Context object represents the parent of an object in Lua. If the Context is null, the object will be global in Lua. Must be of type uLua.LuaMonoBehaviour.

Implements uLua.ILuaObject.

◆ Handle

string uLua.LuaClass.Handle
get

Used to access the unique Handle of a Lua object.

The unique Handle of a Lua object is defined as: Context.Name. If an object's context is null, its unique handle is simply its name.

Implements uLua.ILuaObject.

◆ IsExposed

bool uLua.LuaClass.IsExposed
get

Used to track if an object has been exposed to Lua.

Objects may be marked as exposed by calling the Expose() method.

Implements uLua.ILuaObject.

◆ Name

string uLua.LuaClass.Name
getprotected set

Used to access the name of an object.

The name of an object cannot be changed after it has been exposed to Lua.

Implements uLua.ILuaObject.

◆ this[DynValue Key]

DynValue uLua.LuaClass.this[DynValue Key]
getset

Returns a Lua value indexed by the DynValue Key.

This indexer may be used in Lua or within C# to access any member of a Lua object.

Implements uLua.ILuaObject.

◆ this[string Key]

DynValue uLua.LuaClass.this[string Key]
getset

Returns a Lua value indexed by the string key.

This indexer may be used in Lua or within C# to access any member of a Lua object.

Implements uLua.ILuaObject.