lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Tim,

First of all, I'd like to suggest that sometimes as a programmer you will have to bang your head off something for a while before it clicks. Lua is worth investing some time in, but you can't expect to learn a complete language in a few of days (I've been using Lua for a few years and still find new ways of implementing things regularly).

The Lua manual is quite like a Bjarne Stroustup C++ book. It's very terse, but all the information is there is you take time to read it. You should also read the Lua book (available on the website in .pdf and .ps formats).

From reading through your (extremely verbose) mails, I gather that you want to have multiple game entities controlled by Lua scripts that deal with their decision making and movement. As in Extreme Programming, it's often useful to do the simplest thing that works and work from there.

The last game we wrote did exactly this and basically follows the simple object oriented ideas described in the Lua book

This is how we did it:

Objects are created in Lua that have pointers to c++ objects. Each object has an init() tick() and destroy() function. When an object is created, the resources for the object are loaded and a pointers are returned and stored in the Lua object, the object's init() function is called, and the tick() function is created as a coroutine. Each frame we iterate over all the objects resuming their tick coroutines, they do some processing (calling host functions) then yield. Objects are destoryed explicitly at which point their destroy() function is called.

That's it, it's really simple and works well.

I would also suggest that you try to be more concise in your postings, It's much easier to help when there's a clearly defined question ;)

Rob