lua-intf icon indicating copy to clipboard operation
lua-intf copied to clipboard

Getting pointer to the object from the Lua stack with LuaRef?

Open eduardodoria opened this issue 8 years ago • 1 comments

I'm attempting to get the pointer of C++ object created in Lua.

This is Lua script example:

objecttest = Image("file.png")

How I get this object pointer in C++:

Image* image = NULL;
 
lua_getglobal(L, "objecttest");
if (lua_isuserdata(L, -1))
    image = LuaIntf::CppObject::get<Image>(L, -1, false);

Is this the best way? Or is there any way to get this with LuaRef?

Thanks!

eduardodoria avatar Jun 06 '17 01:06 eduardodoria

LuaIntf::Lua::getGlobal<Image*>(L, "objecttest") would be fine

SteveKChiu avatar Aug 25 '17 02:08 SteveKChiu