Passing a C++ struct and use its method within a Lua function #32
Unanswered
dazzabaijan
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently I have a
Msg
class that I'm looking to pass into a Lua function, and within the function it'll call setters/getters or other methods of theMsg
class based on certain rules i.e. if-else statements. As a prototype, here's theMsg
class that I've been using to test the bindingThe Lua script e.g. test_function.lua may look something like
In the main of my test code, I've been able to make it work using
Now, this works for now, within this test code. My first question would be could you comment on whether that's the correct way to do it? If not what's the better way to do it?
In my actual code, it'd simply look in directories for other different Lua files and load the bindings so they can be used. However, once I started to incorporate the changes above, it'd seem that the
luaaa::LuaClass
constructor does work sometimes, but often times it'd hit the following error(shown on gdb):So for whatever reason, it looks like whatever string name I've given to the
LuaClass
object would sometimes be assigned to the klassName variable, and from there it would fail theassert(klassName == nullptr);
line sinceklassName
is no longer anullptr
. Any ideas why this might be happening? Is my usage of your binder incorrect?Beta Was this translation helpful? Give feedback.
All reactions