• entries
101
122
• views
57907

# Started Lua

117 views

I've been playing around with using Lua as a scripting language for NPCs and possibly even some AI for the monsters.

Didn't get too much done, just got it embedded in a small C++ app with the ability to send and retrieve variables that a lua script processes. Next up is learning how to register some C++ functions and calling them from within a lua script. Looks easy enough.

Also might look around and see what other scripting languages that can be embedded in a C++ app are out there, and decide which one to use.

I liked the look of AngelScript.. I have yet to try it though. It's an alternative to Lua :).

I've used Lua on several occasions and have been quite happy with it.

was it pretty easy to get in to your application? I dont need a scripting language *yet* but I can see the time when I would. If you get in to Lua, would you mind pasting any useful urls you may have used for reference in to this journal?

Cheers [smile]

It was pretty easy, downloading lua and getting a hello world script running from a C++ app took maybe an hour. Getting a lua script to do something a bit more interesting wasn't much harder.

The two references i've used are this article here at gamedev.net and the book Core Techniques & Algorithms in Game Programming by Daniel Sanchez-Crespo. The book only has 4 or 5 pages specifically on lua, but it's well written.

The biggest annoyance so far is that anytime you want to include lua.h in a C++ file you have to do it like this:
extern "C"
{
#include <lua.h>
}



One problem i've noticed with the tutorial is that it appears to be using an older version of lua (4 I think), so it expects the function lua_open() to be:

lua_State *lua_open (int initialStackSize);

Where in lua 5.0.2 (what i'm using) it appears to have been changed to:

lua_State *lua_open (void);

## Create an account

Register a new account