Sign in to follow this  
ricekrispyw

LuaBind

Recommended Posts

I'm wondering about using LuaBind in my current project, but I've never *gasp* used real scripting before. By real scripting, I mean anything but loading a set of actions that define something, an animation sequence for instance, and I was wondering just how much work it takes to use LuaBind in a project. Here's the meat of the post: Could someone post some sample code of what it takes to use LuaBind in a basic way. Say, create a class in C++, and call a member function in LuaBind. Or, define a class in C++ and extend it in LuaBind. Thanks in advance.

Share this post


Link to post
Share on other sites
LuaBind seems to be nice, I've never tried. However, toLua looks even nicer (less extra work to do), but I've never tried that either. I suggest you take a look at both and then decide which to use.

-Richardo

Share this post


Link to post
Share on other sites
Cool. Thanks. I've glanced at the docs for LuaBind, but I was wondering if there was something maybe they weren't telling. I'll take a closer look.

I've never heard of toLua. Is it also on SF? Well, I'll just [google] it.

Thanks, y'all.

Share this post


Link to post
Share on other sites
toLua does look nice, but I see nothing about deriving lua classes from C++ classes (or even creating lua classes in the first place...)

I can't find out how to build LuaBind. I'm on WinXP, with VC6. How do I do it? And how much of boost do I need? The entire monstrosity?

Help me, please.

Share this post


Link to post
Share on other sites
Classes in lua are only faked (using an additional hidden parameter), and deriving classes from C++ is not directly possible, you can however map functions to c-functions in Lua and thus using C++-classes in Lua.

And as far as I know, regular Lua was very easy to get up and running.

Share this post


Link to post
Share on other sites
Quote:
Original post by ricekrispyw
toLua does look nice, but I see nothing about deriving lua classes from C++ classes (or even creating lua classes in the first place...)

I can't find out how to build LuaBind. I'm on WinXP, with VC6. How do I do it? And how much of boost do I need? The entire monstrosity?

Help me, please.

Instead of building it, you can just include the cpp files in your main project.. Obviously, that's not as clean as compiling it into a lib but it works. I'm not sure how much of boost you need, but imo you should just get the whole package anyway, there are a lot of very useful things in there (and I think the headers are enough for luabind, so you don't need to build that either).

Share this post


Link to post
Share on other sites
Hmmm... OK. Hmmm.

I really don't want the tremendous beast that is boost right now. I realize it's really useful, but I'm not using it, and I would hate to have it just for LuaBind. I have seen nothing else that lets you derive Lua classes from C++ ones (which you can do in LuaBind), so I might not have a choice. Oh, well. Thanks.

Share this post


Link to post
Share on other sites
LuaBind is very nice, but it is black magic that works but most programmers do not understand how it works. Try to track down where the code that passes parameters between the interpreter and your code, try to understand it, and try to debug it. Very few people really understand what REALLY is going on on LuaBind (or Boost.Python), which means that if you ever need you debug something internally on the glue layer you need to find somebody that can help you out.

Share this post


Link to post
Share on other sites
Quote:
Original post by ricekrispyw
And how much of boost do I need? The entire monstrosity?


From the introduction:

Quote:

It requires boost 1.30.0 to be installed (only boost headers).


I'd hazard that you need only the headers.

Share this post


Link to post
Share on other sites
Quote:
Original post by ScootA
I'd hazard that you need only the headers.

Those are still pretty huge. I've changed my current project and I'm now only going to be using scripting as sort of a glorified config file, but I mean REALLY glorified. So I'm gonna go with probably AngelScript.

Thanks for all the feedback, though. And for my next game I very well may use Boost and LuaBind.

Take care.

[Edited by - ricekrispyw on July 13, 2005 11:50:52 PM]

Share this post


Link to post
Share on other sites
I do not think luabind is very good at all. It doesn't work with gcc 3.4 or greater. I spent quite some time in an attempt to get it to work with gcc 3.4 and in that time I became somewhat familiar with the codebase and I must say it is mostly crap imho (ie not such good design). But to a user of the library I guess the internals don't matter as much.

so, I guess if you are using a compiler that it does work with then it is moderately decent.

My personal recommendation is don't use luabind. I'd recommend if you are "serious" about using lua to play with the lua api for a little bit at first and then settle in on a C++ lua wrapper that is a little more light weight, and/or write your own which does only what you need.

Share this post


Link to post
Share on other sites
Given the advanced template programming techniques the make up LuaBind, its developers need to have a least several years of experience. My personal impression on LuaBind's code quality was that it is exceptionally good. Clean, modular, exception-aware and well readable.

If you google for 'LuaBind', you should also find a tutorial I've written as one of the first results ("Quick Introduction to LuaBind). That tutorial also links to precompiled lubaind binaries and an out-of-the-box compiling and working Visual Studio .NET 2005 project which requires no configuration changes or library installs whatsoever on your system. Might be of use when making your first steps in LuaBind.

-Markus-

[Edited by - Cygon on January 12, 2007 6:58:13 PM]

Share this post


Link to post
Share on other sites
It is true that in the most part the developers of Boost are experienced and understand template metaprogramming very well. The problem is that IMHO most people end up integrating something that they do not even know how it works. Maybe the library is good, but the programmer that uses it usually does not understand very well what is going on under the covers, and if that is the case that programmer is likely to write something that the library does not support, and the library being a template black magic library will fail in different ways under different compilers.

My advice is to integrate LuaBind only if the interested person is willing to spend time understanding what is happening under the covers.

Share this post


Link to post
Share on other sites
Boost developers are indeed quite knowledgeable, if it is in boost I tend to assume it is "good"; however, luabind is not coded by boost developers, it just requires the boost libs... well correct me if I am wrong but at least Daniel Wallin and Arvid Norberg (authors of luabind) are not listed as boost developers on boost.org (and actually I am getting really off topics I think)

Share this post


Link to post
Share on other sites
The creators of LuaBind are probably no listed, but LuaBind uses the same mechanism that Boost.Python uses, they ported most of the functionality which was created by David Abrahams originally (A respected Boost developer)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this