This snipped works for basic types:
int CreateBasicObject(lua_State *L)
{
int ret0;
lua_pushinteger(L, ret0);
return 1;
}
and in lua it looks like this:
local NewObject=CreateBasicObject()
How would I go about returning classes instead of ints?
push(L,&MyObject);
return 1;
does not seem to work correctly, lua portion looks like this:
self.MyObject=Screen.MyObject();
And the error is:
attempt to index field 'MyObject' (a number value)
In the newest LuaBridge version you can use
RefCountedPtr
for example:some C++ definition
and the binding:
now you can return
A
objects safely and pass them to other Lua-bound functions asRefCountedPtr<A>
in lua you can then use it like that: