Sending a global to lua
Moderator: Coders of Rage
- WSPSNIPER
- Chaos Rift Regular
- Posts: 145
- Joined: Sun Jan 03, 2010 6:19 pm
- Current Project: top down shooter
- Favorite Gaming Platforms: ps3
- Programming Language of Choice: c++
Sending a global to lua
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
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Sending a global to lua
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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Sending a global to lua
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.
- WSPSNIPER
- Chaos Rift Regular
- Posts: 145
- Joined: Sun Jan 03, 2010 6:19 pm
- Current Project: top down shooter
- Favorite Gaming Platforms: ps3
- Programming Language of Choice: c++
Re: Sending a global to lua
sweet thanksGyroVorbis 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.