Now, each monster (or NPC in general) has a Think script object that is executed each time the monster needs to figure out what to do next. Eventually, I may either do multiple levels of Think (for level of detail reasons), or I'll finesse the Sleeping state to not call Think, and only when an event has occured to disturb the monster from Sleeping to Idle or other, only then will Think be called. Should save the performance hit of calling Think on monsters far off-screen and non-disturbed. Alternatively, if I go with a level-of-detail AI, monsters would have separate scripts for each level. However, I don't really want to be calling Think on Sleeping monsters, so it is likely I will not go this route.
I'm currently struggling with a bit of a problem. It is possible to compile Lua script down to bytecode for possibly faster execution times, something that would certainly be desirable for a Think script since they may be called by many objects every update. However, I have yet to find an obvious way of pre-compiling a loaded script to bytecode and being able to execute it. Right now, I'm simply storing the plain-text strings for the scripts, which can be either loaded from file or generated on the fly as necessary. However, every time the script is executed it must be compiled on the fly, and I would like to do away with this intermediate compilation. Perusing the source for Lua 4.0 (which this project uses, based as it is on old Accidental code) I can find no immediately obvious way of doing this. The only code paths that seem to handle compiled bytecode are along the lua_dofile route, and there is weirdness in that code path that defies easy implementation of what I have in mind. I'm pretty sure I can hack something together. Phantom is helping me on this problem as well, so hopefully between the two of us we can figure out the best way to do this.
I might get around to posting a few images sometime this weekend, when I've prettied up a few things. Then again, I might not. We'll see.