Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently planning how to integrate Lua scripting in my 2D Game Engine, and i would like to go straight to the most adequate solution for having C++ classes and objects exposed.

I've read this (if it helps you help):

If you have a better scripting language to recomend, go for it ;D

All help is welcome, i need to pickup the best solution to start implementing Thanks

share|improve this question

closed as off-topic by Josh Petrie Apr 21 '14 at 2:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about "how to get started," "what to learn next," or "which technology to use" are discussion-oriented questions which involve answers that are either based on opinion, or which are all equally valid. Those kinds of questions are outside the scope of this site. Visit our help center for more information." – Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 3 down vote accepted

If the primary quality of your scripting language is easy binding, try AngelScript. It can call registered functions directly without the need to write proxy functions, and it supports calling conventions of wide variety of compilers. The language itself is similar to c/c++, which may be a good or a bad thing, depending.

share|improve this answer

I've heard good things about LuaPlus. It wraps the low level C API into a higher level C++ one.

share|improve this answer
+1 Thanks for this, something to look into soon :) – Ray Dey Jan 29 '11 at 15:50

As long as you're doing reasonably conventional binding, LuaBind will do everything you need. Binding classes and functions tends to be a one-line-per-function deal. If you'd like an example, here's the applicable file from the game engine I've been working on (look for module(L) for the start of the LuaBind interface, DontKillMeBro<> is a little system I rigged up to let me more precisely time object destruction for certain sensitive objects.)

If you want something more complex, you're probably going to need to use the actual Lua API. Luckily, the Lua API is reasonably simple.

share|improve this answer

I'd go hands down with Nuclex's precompiled libs and include files for LuaBind. (that is if you're working with VS2008)

Since LuaBind requires you to build it with some Boost libs and tools, this package will save you valuable time (and maybe some headache, who knows). I'd say you'd be able to get Lua running in less than an hour if you know what you're doing.

You may also consider changing the default Lua dll to a LuaJIT dll if you're looking for a small performance gain. It's only a matter of compiling the library and replacing the lib/dll you're linking against in your main project, so it's quite easy.

With that, good luck!

share|improve this answer

We're using OOLua for Pioneer. It gives a pile of macros that you use to bind Lua "classes" to C++ classes. Its got a fair bit of power but is pretty straightforward. I haven't used any others so I can't comment on how it compares. Here's an example.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.