Page 1 of 1
Lua Wrapper
Posted: Wed Nov 12, 2008 4:45 pm
by avansc
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.
Re: Lua Wrapper
Posted: Wed Nov 12, 2008 4:50 pm
by Falco Girgis
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.
Re: Lua Wrapper
Posted: Wed Nov 12, 2008 5:02 pm
by unholysavagery
Why do people use wrappers for lua when it's already so simple?
Re: Lua Wrapper
Posted: Wed Nov 12, 2008 5:11 pm
by MarauderIIC
Because writing wrappers for every member function manually would be a pain in the butt.
Re: Lua Wrapper
Posted: Wed Nov 12, 2008 5:33 pm
by M_D_K
MarauderIIC wrote:Because writing wrappers for every member function manually would be a pain in the butt.
Exactly. Also another good wrapper is SWIG it works in a similar way to toLua++.
Re: Lua Wrapper
Posted: Wed Nov 12, 2008 6:48 pm
by Falco Girgis
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.