1

I'm just looking for solution how to pass object from C to lua callback as function argument, is it even possible? I cannot find any referece. just trying something like this:

luabind::call_function(State, "Callback_name", object);

but luabind is not a option in this case because it is obsolete and additionally some features just don't work that's probably because of boost as I read but don't know exactly, thats why I switched to toLua++ but still cannot find any solution for it. I'm just trying to achieve to access data from C in lua callback ex:

function LUA_Callback(object1, object2)
    print(object1.name)
    print(object2.size)
end

Is there any way to solve it or library(without boost) to do this?

1 Answer 1

1

That depends on what you mean by "push object". It's trivial to push numbers, strings, C functions, tables, etc. -- in other words, Lua objects -- using API routines like lua_pushstring, lua_pushnumber, etc.

If you're talking about pushing C++ objects, you need to create and push userdata. If you want them to behave like objects from Lua, then you'll need the appropriate metatable/methods.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, I want to push C++ objects and I want to to behave them like objects in Lua too, could you give me any reference about that? Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.