Page 1 of 1

Sending a global to lua

Posted: Thu Jun 10, 2010 5:12 pm
by WSPSNIPER
hello, im using lua in one of my projects and trying out different c++ binding libs. So far i like luabridge and luabind ( lua bridge more because of no boost ) i can export a class to lua now but not a class instance. for example if i use the class in lua the data dose not come back to c++. i would like to know how you can create a class in c++ and send it to lua, update it, and give it back to c++ updated. i dont care what lib for binding if any i just want it to work. Thanks for your help

Re: Sending a global to lua

Posted: Thu Jun 10, 2010 9:27 pm
by dandymcgee
I haven't used lua in a while now, but I believe if you register a class and a function with luabind you can send a class instance to the function as a parameter (and I imagine vice versa), thus allowing you to pass a reference between lua and C++. Now there may be a better way, so don't mistake what I to be expert advice.

Re: Sending a global to lua

Posted: Fri Jun 11, 2010 10:46 am
by Falco Girgis
Yeah. If you are using some kind of wrapper to bind C/++ functions to Lua, it should be as easy as returning a reference or pointer to an instance.

Re: Sending a global to lua

Posted: Fri Jun 11, 2010 5:07 pm
by WSPSNIPER
GyroVorbis wrote:Yeah. If you are using some kind of wrapper to bind C/++ functions to Lua, it should be as easy as returning a reference or pointer to an instance.
sweet thanks