lua-users home
lua-l archive

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

Sebby wrote:

> Hi.
> I'm a software engineer for a video game company. We currently need a
> scripting language to control various parts of our next generation of
> games (AI, SFX, animation, GUI, ...). Oour original plan was to write
> our own compiler + VM (i have written some in the past so it's not an
> unfamiliar territory for me).

Lua would be an excellent choice for that, especially if you use the
upcoming Lua 4.0, which will be greatly enhanced over current versions.
Older versions of Lua have been used in other commercial game product:
Baldur's Gate and MDK, for example.  (And Baldur's Gate being my most
favorite game, Windows-only or not, I'd be quite impressed with Lua with
that fact alone, even if I didn't know Lua was so excellent!).

> However, now i have stumbled on Lua and wonder if it would be a
> viable alternative. Writing our own compiler and VM would be time
> consuming where as i am assuming i can have Lua integrated into our
> engine in 1-2 days of coding (versus a few weeks for our other
> alternative).

Yes, it would.  Truly, writing any kind of compiler/VM specifically for
one project in today's time is Just Plain Stupid (tm), looking at the
good assortment of excellent embeddable scripting language: Python,
Ruby, TCL, Scheme, and (of course) Lua.

> So to help me make my decision, there is a few questions and points
> i'd like to ask about.
> * Lua being dynamicly typed, i can see the advantages especialy
> considering some of the code might be written by non programmers.
> However, since type determination is moved from the compiler to the
> VM, what is the actual runtime cost of dynamic types?

I don't know on this one, but I'm assuming it wouldn't be much.  I've
actually found many languages such as Lua (Ruby, for example) run faster
than strongly typed languages such as Java in most situations.  I'm not
sure about Lua, however.  I've no benchmarks.

> * Lua can be extended through function calls. Unfortunateley, this
> implies writing a stub function to grab the parameters from the Lua
> stack and call the actual function (this is pretty much the same
> thing i did with a VM i did, except it could also call functions in
> objects in C++). Now, i'v heard mentioned somewhere in the mailing
> list there was a more efficient way of extending Lua. Is that so? And
> how?

There are many such ways (not sure which one you have heard of).
Writing a simple "stub-function-interface" and merging it with Lua and
your engine should be a piece of cake, no more than an hour or two, from
my own experiences.  For another language, I've written a set of C-style
macros that actually build the stub-function for me.  A C++ template
class could also be generated quite easily.

Also, there is SWIG.  I think there is an unofficial module for
SWIG+Lua, though I'm not sure.  Perhaps someone else knows of this?

> * Since our next generation game engine will work on a limited set of
> platforms (PC, Playstation 2, X-Box). How hard would it be to write
> optimized versions of the VM for such different plateforms?

Look at the code.  It's a matter of style really, and what you mean by
optimized versions...  I shouldn't think it be too difficult, though.
Certainly easier than writing your own multi-platform VM from scratch.

And what's this?  No Linux?  No Indrema Entertainment System?
Disappointing...  I'd think that a Linux or Indrema port would be a bit
simple if you're developing for the PS2.  Your loss... ~,^

Anyways, I hope I was able to assist you in your decision.  Lua is an
excellent choice for a game engine, for sure.

Sean, Etc.

> Any feedback will be greatly apreciated.
> Sebastien St-Laurent
> Z-Axis ltd.