Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eduardodoria opened this issue Jun 6, 2017 · 1 comment
Open

Comments

@eduardodoria
Copy link

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!

@SteveKChiu
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants