Skip to content

luaclass

asqbtcupid edited this page Feb 5, 2018 · 4 revisions

For pure Lua class

1. NewClass

local NewClass = Inherit(Object)

Object is The most basic class.You can inherit another class:

local NewClassChild = Inherit(NewClass)

2. New Ins

local Ins = NewClass:NewIns(...)

It will call parentclass's Ctor function firstly.Then call childclass's Ctor function.

... paramter will be passed to Ctor

3. Release Ins

Ins:Release(...)

It will call childclass's Destroy function firstly.Then call parentclass's Destroy function.

... paramter will be passed to Destroy

4. Ins Call function

Ins:functionname(...)

It's will search childclass firstly,Then search parentclass.

if you want to call parent function to this ins:

ParentClass.functionname(Ins, ...)

For Class with c++

allmost the same as pure lua class.

Difference:

1. The most basic class is CppObjectBase

local NewCppClass = Inherit(CppObjectBase)

2. Can't Call NewIns

instead:Class:NewOn(inscpp, ...)

3. Call Function

Will search luafunction firstly then cppfunction.

Create Lua ins for c++ ins

Use the LuaCtor macro in c++.c++ call lua

Use the LuaCtor Node in Blueprint.bp call lua

After LuaCtor.A Lua ins will be created and represent the c++ ins in the Lua.

when you try to get the c++ ins in lua, you will get the Lua ins.

When you pass the Lua ins to c++, It will switch to the c++ ins.

Think about Blueprint,In Blueprint, The c++ ins switch to Bp ins.

When in c++, the Bp ins switch to c++ ins.

Lua class works like this.