Reputation: 67749
So I have heard that Lua is a good scripting language that ties into C++. Does anyone know some good resources for picking it up, for someone with lots of C++ experience?
Upvotes: 3
Views: 1137
Reputation: 21
First off all see http://www.lua.org/manual/5.1/manual.html#3. It's very easy to integrate Lua and C++. But for large programs I'd suggest to use swig.
Upvotes: 0
Reputation: 8717
You may want to look at toLua++ or Luabind for C++ integration.
As far as learning lua itself goes, the Programming in Lua book or even the Lua Reference Manual shouldn't be out of your league at all; see the documentation section of the lua website.
The usual rule applies: read lots of other code when you're getting started. If it's your cup of tea, you could e.g. go dig though World of Warcraft addons for some (admittedly specialized) real-world examples.
And listen to the community: subscribe to some mailing lists, take a look at the lua-users resources (especially the wiki), et cetera.
I work at a game development company, and we use primarily C++ and lua together. We don't actually use Luabind or toLua++ yet (mostly just a lack of time to test and integrate them), but a few things we've learned:
lua_setallocf
to change allocator behavior -- constrain it to its own area of memory to prevent fragmentation, and take advantage of a more efficient small object allocator (perhaps boost::pool) to reduce overhead (other ideas in an earlier answer)index
and newindex
has proved especially useful for usUpvotes: 9
Reputation: 4435
These might give you an idea of where to start. The Lua C library is a bit low-level than you might expect with regards to getting your own C++ code mixed into the Lua virtual-machine etc, but have a look at these anyway.
http://www.codeproject.com/KB/cpp/luaincpp.aspx
http://heavycoder.com/tutorials/lua_embed.php
Upvotes: 1