I have this Lua code:
function returnPerson()
local person = Person("Mike", 23)
return person
end
It returns userdata representing Person(C++ class registered using LuaBridge). So I call this function using lua_pcall and now the last element of the lua stack is that userdata. My question is how do I convert(cast) this userdata at -1 back to Person in C++.
I tried this, but it just terminates the program:
LuaRef lref_p(l);
lref_p.fromStack(l, -1);
Person pers = lref_p.cast<Person>();
I hope it makes sense :)