Lua... wow

Archived from groups: (More info?)

I'm still grinding out code for my horror RL, set in my hotel, and
I've gotten further on this project than any other roguelike I've
worked on. Throughout development, I've only been using two
libraries, SDL, and Lua. SDL, I've been messing around with for a
while. It's simple, and fun to use, and that's all there really is to
say about it. Lua, I've also played around with before, but this is
the first time I've actually used it on a large project. And all I
can say is, wow.

Right away, I tied in scripting abilities. Not a single aspect of
development has gone untouched by Lua's magic. Firstly, I scripted
the loading of all resources. Images, fonts, sound effects, music,
all loaded through scripts. I've been able to use that functionality
to make rapid changes to the visual and audio aspects of the game, and
make smarter decisions. In less than 30 seconds, I can change the
image initialization script and see whether the green carpet or the
red carpet looks better in the atrium.

Another interesting possibility to consider, when dealing with
initialization scripts, is the possibility of easy modding. A player
who, say, wants to replace a particular song in the game, with one of
their own, can do so in a few seconds. A dedicated modder could
splice in new graphics, either to make the game creepier, or for humor
value (replace the main character's sprite with Mario or Sonic).

As for the actual bulk of the game, I eventually decided to do a
trigger/event system, somewhat akin to Starcraft. Each room/level can
have any number of scripts running. Once every x milliseconds, every
script's triggers are checked, and, if true, the script is run. Also,
every object has a script associated with it, allowing for a great
deal of functionality and customizability.

For example, a script for a monster might look something like this:

function onCollision(object obj)
blah blah blah

function onAttack(object obj)
blah blah blah

function onDamage(object obj)
blah blah blah

etc, etc, etc.

I'm in love with Lua. My game is slowly evolving into a (somewhat)
generic RL engine, without me trying to. I figure, that I should be
able to make my next RL with *significantly* reduced development time,
which, for me, is great.

Anyway, there was no real point to this thread, except to describe my
experience with Lua on this larger project. Anyone out there who is
planning on using datafiles in his RL should *definitely* look into
using Lua. Even if you don't take full advantage of the scripting
capabilities, it is still a far superior way of inputting data, as
opposed to the old method of manually parsing some text (or binary)
file. Not only is Lua great for using as datafiles, but, you get the
full benefits of having a scipting language as well. One example that
comes to mind: conditional data loading.

Well, I've blabbed on long enough. Time to get back to work.

My projects are currently on hold, but I do have
some junk at the site below.

3 answers Last reply
More about tomshardware
  1. Archived from groups: (More info?)

    Will you opensource this once finished ?

  2. Archived from groups: (More info?)

    Duh, it's a script, please ignore that ;)
    It's a friday and high gas prices drove me nuts.

  3. Archived from groups: (More info?)

    konijn_ wrote:
    > Duh, it's a script, please ignore that ;)
    > It's a friday and high gas prices drove me nuts.

    It's not all script. It's C++ with heavy Lua scripting embedded.
    But, yes, it will all be open source. I think there is a lack of good
    examples of SDL and Lua code, so any contribution I can make will be
    useful in expanding the resource base for my favorite two libraries.

    My projects are currently on hold, but I do have
    some junk at the site below.

Ask a new question

Read More

Development World Of Warcraft Games Video Games