As I understand it, this requires a nativeObject context which has a registered callback handler. I was looking to call an arbitrary global lua function. Though the correct use of handleEvent still confuses me somewhat
Are there any tutorials, examples or even documentation for the use of LuaEngine for custom types and functions? The Lua examples provided along with cocos2d-x use one script as an entry point and everything from that point happens via cocos2d-x bindings as far as I can tell.
–
I have been able to work out how to send objects to lua by bypassing LuaEngine, but was hoping there was an exposed solution through LuaEngine since cocos2d-x does similar work internally:
//get function that returns a Node
lua_getglobal(stack->getLuaState(), "luaFunc");
//call function
lua_call(stack->getLuaState(), 0, 1);
//retrieve return value
Node* child;
luaval_to_object<Node>(stack->getLuaState(), -1, "cc.Node", &child);
//remove return value from statck
lua_pop(stack->getLuaState(), 1);