Skip to content

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

Description

@eduardodoria

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions