Oct 12 2008

Adding Lua

Published by at 5:03 pm under Code

I spent the afternoon adding Lua to my code.  It only took about an hour to get the Lua library compiling and running.  The rest of the time was setting up the various hooks to make the scripting language actually functional.  I did not have time to add an interactive parser, that is on my list of things to do.

I have used Lua on previous games and never been that happy with it.  It tends to run slowly and require more memory than you would expect.  Also, most people tend to use it during development by reading in text files and doing on demand parsing.  This scares me since I prefer doing type checking and variable checking at a compile time…one typo and suddenly your run-time can blow up.  In some games, I have made the memory allocator throw an assertion if someone tried to allocate a var, string, etc. that was not seen before.  This seems to stop the typo problem, assuming that the game (and testers) have coverage over every script.

There is always a trade off between writing your own scripting language and using a prebuilt one.  I think a lot has to do with how much time and customization you require.  At Stormfront Studios, level designers never wrote any scripts by hand, but used a visual editor which made machine generated scripts.  Since most of those games were level-based, adventure games, most of the game play was triggers.  This meant that if there was an error, we needed to know immediately.  It also meant that the games ran everything in script (back on the PS2) so performance and memory was serious issue.  On MySims, the “level designers” were engineers who wrote scripts all day.  They were comfortable with full blown programming languages and encoded the actual game play and mini-games into the scripts.

No responses yet

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.