UnLuaNova API¶
C++ API¶
Global Variables¶
-
UnLuaNova::GLuaSrcRelativePathRelative path of Lua script source files based on Content directory -
UnLuaNova::GLuaSrcFullPathAbsolute path of Lua script source files -
FLuaContext::GLuaCxtGlobal Lua context
Global Functions¶
Namespace of UnLuaNova
* Call Call a global function in Lua.
-
CallTableFuncCall a function in a given global table in Lua. -
GetReturn a given type value from the Lua stack at the given inde -
Push/PushXXXPush a data with given type into the Lua stack -
IsTypeReturn the data in Lua stack at given index is the given type or not -
CreateStateReturn global lua_State pointer created in FLuaContext class -
GetStateReturn the global lua_State pointer created by CreateState -
StartupCall to start the UnLuaNova, return true for success start, otherwise, return false -
ShutdownCall to stop the UnLuaNova -
LoadFileCall to load a Lua file with relative path based on Lua Script path without running it, return true if found the file and loaded successfully, otherwise return false -
RunFileCall to load and run a Lua file, return true if loaded and run successfully, otherwise return false -
LoadChunkCall to load a Lua chunk without running it, return true if loaded successfully, otherwise return false -
RunChunkCall to run a Lua chunk, return true if loaded successfully, otherwise return false -
ReportLuaCallErrorReturn Lua error, will excute the error delegate if the error delegate was bounded, otherwise will callUE_LOGto output the error. -
GetStackVariablesGet local variables and upvalues of the runtime stack. -
GetLuaCallStackGet the call stack of the running lua_State
UnLuaNova's global Delegates¶
FUnLuaNovaDelegates
* OnLuaStateCreated Trriged after created a lua_State, you can get the lua_State in this delegate
-
OnLuaContextInitializedTrriged after UnLuaNova's context has been initialized -
OnPreLuaContextCleanupTrriged before starting to clean UnLuaNova's context -
OnPostLuaContextCleanupTrriged after UnLuaNova's context has been cleaned -
OnPreStaticallyExportTrriged before starting to register the statically exported classes into lua_State -
OnObjectBindedTrriged after an UObject has been binned with a lua file -
OnObjectUnbindedTrriged after an UObject has been unbinned with a lua file -
ReportLuaCallErrorTrriged after Lua VM occured an error, could register user-defined implementation -
ConfigureLuaGCTrriged after lua_State was created, could register user-defined lua gc configuration -
LoadLuaFileTrriged while try to loading lua file, could register user-defined loading
Interface¶
UUnLuaNovaInterfaceCore interface for UnLuaNova, used to tell UnLuaNova which UE-Object should be bind with Lua file
Class¶
-
FLuaContextWrapper of UnLuaNova's context, contains the main lua_State of UnLuaNova -
FLuaIndexWrapper of the index of Lua stack -
FLuaTableWrapper of Lua table, could get tables's data by[], and also support call a function -
FLuaValueWrapper of generic Lua value -
FLuaFunctionWrapper of Lua function, could be global function or funciton in global table -
FLuaRetValuesWrapper of Lua funciton's return value -
FCheckStackHelper for checking Lua stack is correct or not -
FAutoStackHelper to recover Lua stack automatically -
FExportedEnumInterface for exporting enum into lua
Lua API¶
Global Tables¶
UECould useUE.UEClassto access class in c++ if you openWITH_UE4_NAMESPACE, otherwise, could access class in c++ by_G.UEClass. Class will be registered into Lua while being used, so don’t worry about the performance problems caused by too much loading at one time.
Global Functions¶
-
RegisterEnumUsed to manually register an enum into Lua -
RegisterClassUsed to manually register a class into Lua -
GetUPropertyReturn the UProperty of given UObject by given name -
SetUPropertySet the value of given UProperty in given UObject with given value -
LoadObjectLoads an UObject, same asUObject.Load("/Game/Core/Blueprints/AI/BehaviorTree_Enemy.BehaviorTree_Enemy -
LoadClassLoads a UClass, same asUClass.Load("/Game/Core/Blueprints/AICharacter.AICharacter_C -
NewObjectCreates an UObject with given Class and Outer(Optional) and Name(Opthional) -
UEPrintWrapper ofUE_LOG, internally useUKismetSystemLibrary::PrintString
Functions of Instances¶
InitializeAssuming that every Lua Table has this function, it will be called when binding with UObject
Functions for UE Delegate¶
-
BindBinds the given lua callback with the given instance of FScriptDelegate -
UnbindUnbinds the lua callback of the given instance of FScriptDelegate -
ExecuteManually excutes all callbacks of the given instance of FScriptDelegate
UnLuaNova.lua (Functions in UnLuaNova.lua)¶
-
ClassCreate a table like class in OOP -
printOverride originprintbyUEPrint
Macros in UnLuaNova module¶
-
AUTO_UnLuaNova_STARTUPMacro for whether to automatically start or not, default is true -
WITH_UE4_NAMESPACEMacro for whether to useUEto access Unreal Class's in Lua or not , default is true -
SUPPORTS_RPC_CALLMacro for whether to support RPC calls, default is true -
SUPPORTS_COMMANDLETMacro for whether to support UnLuaNova incommandlet, default is true -
ENABLE_TYPE_CHECKMacro for whether to check arguments' type is correct or not while calling C++ from Lua, default is true -
UnLuaNova_ENABLE_DEBUGMacro for whether to output UnLuaNova's debugging log, default is true.
Further reading¶
- Programming Guide — Binding, two-way calls and garbage collection
- How To Implement Overriding — How overriding works
- FAQ — Frequently asked questions