Lua Wrapper
Moderator: Coders of Rage
Lua Wrapper
hey, i have never really used a scripting language as part of a game, and guess i'll go with lau, just wondering what the best wrapper for it was.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
- 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: Lua Wrapper
There are two good ones: toLua++ and LuaBind. I know that trufun202 is using LuaBind, and we are using toLua++.
The basic differences are that LuaBind uses "template meta programming" to dynamically create the wrapper code. toLua++ generates wrapper .cpp files that you manually include with your project.
It takes longer to compile with LuaBind, because it's dynamically creating the wrapper code. LuaBind may also have certain features that toLua++ doesn't have (I'm not really sure, because I have never encountered or needed them). LuaBind also requires the Boost header files and is seen as much more heavyweight than toLua++.
toLua++ has a very small library that you link to with your project that the generated wrappers utilize. You pass toLua++ a "cleaned" version of a header file, and it creates all of the wrappers for the various functions/class members that you require. You then compile this with your project.
Both toLua++ and LuaBind give Lua true OO features.
We went with toLua++, because the version of gcc that's on Dreamcast is too old to support some of LuaBind's extreme OO whorism. toLua++ is also more lightweight, so it worked better for a project that needs to run on a console.
I'm sure that trufun can tell you all sorts of good things about LuaBind, though.
The basic differences are that LuaBind uses "template meta programming" to dynamically create the wrapper code. toLua++ generates wrapper .cpp files that you manually include with your project.
It takes longer to compile with LuaBind, because it's dynamically creating the wrapper code. LuaBind may also have certain features that toLua++ doesn't have (I'm not really sure, because I have never encountered or needed them). LuaBind also requires the Boost header files and is seen as much more heavyweight than toLua++.
toLua++ has a very small library that you link to with your project that the generated wrappers utilize. You pass toLua++ a "cleaned" version of a header file, and it creates all of the wrappers for the various functions/class members that you require. You then compile this with your project.
Both toLua++ and LuaBind give Lua true OO features.
We went with toLua++, because the version of gcc that's on Dreamcast is too old to support some of LuaBind's extreme OO whorism. toLua++ is also more lightweight, so it worked better for a project that needs to run on a console.
I'm sure that trufun can tell you all sorts of good things about LuaBind, though.
- unholysavagery
- Chaos Rift Cool Newbie
- Posts: 73
- Joined: Tue Oct 28, 2008 4:27 am
Re: Lua Wrapper
Why do people use wrappers for lua when it's already so simple?
This is the internet, men are men, women are men and children are the FBI.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Lua Wrapper
Because writing wrappers for every member function manually would be a pain in the butt.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- M_D_K
- Chaos Rift Demigod
- Posts: 1087
- Joined: Tue Oct 28, 2008 10:33 am
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C/++
- Location: UK
Re: Lua Wrapper
Exactly. Also another good wrapper is SWIG it works in a similar way to toLua++.MarauderIIC wrote:Because writing wrappers for every member function manually would be a pain in the butt.
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
- 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: Lua Wrapper
Oh yeah, SWIG is also good. It's not just for Lua either (supports Perl, Python, Ruby, blah blah).
And Lua is simple, but when you start doing things like passing references and objects back and forth (and those references contain other objects with complex methods and members and maybe even another object in that object... and so on), it's a pain in the ass.
And Lua is simple, but when you start doing things like passing references and objects back and forth (and those references contain other objects with complex methods and members and maybe even another object in that object... and so on), it's a pain in the ass.