Lua Debugging

Posted by unknownworlds 17 years ago

Update: Our complete Lua debugger (Decoda) is now available here.

As mentioned here previously, we’re doing all of the game coding for Natural Selection 2 in the Lua scripting language. While using a scripting language offers lots of advantages, one of the big disadvantages is that the tools are generally not as good as what’s available for C++ development. The most important of these tools is a debugger, which programmers use to inspect what’s going on as their program runs. This is a valuable tool when trying to find and fix bugs in even relatively simple code, and for something as complex as the code for Natural Selection 2, it’s a necessity.

There are a couple of existing debuggers for Lua, but none that I tried worked for debugging our script code. I’m not sure why that was – possibly operator error – but since Lua has some built-in hooks for writing a debugger and I’ve got quite a bit of experience building UI tools, I figured I could easily create my own. This turned out to be accurate (not something that happens often) and I got a functional Lua debugger working with Natural Selection 2 over the course of a weekend.

What I didn’t realize was that my original design for the debugger wasn’t very good. I’ll spare you the details of how the early version worked, but this is what I discovered once we started using it: for the best work flow the debugger needed to be a separate application from the game and needed to have an integrated code editor — two things my early version lacked. The concept of an integrated development environment (IDE) like this is something programmers invented decades ago, so I perhaps I’m a bit dense.

Armed with that knowledge I starting programming a new script editor/debugger that we have dubbed Decoda (see screen shot above). Charlie and I both have friends that work at other companies that expressed interest in a Lua debugger, so we’ve been developing Decoda with an eye towards licensing it to help fund development of Natural Selection 2. Getting it to the point where it could be effectively used as an IDE took quite a bit more work than the initial weekend for the prototype debugger, but we’re getting close to an alpha build. We’re going to be sending this build to some people for feedback, so if you work for a company that might be interested in Decoda, write us at

To keep this blog entry from being too dry here’s a cool concept painting done by Christian Oesch. I mentioned in the last blog that the concept images we posted before were of the “biomech”art set; this image belongs to what we call the “drytech” set and as you can see it has a bit of a different look.

The purpose of defining different art sets like this – an art set is a collection of textures and prop models that have a similar theme – is so that we’ll have plenty of visual variation between the levels for Natural Selection 2. The level designers for Natural Selection 1 did a great job, but for the sequel we want to give them even more tools to make every level feel unique and memorable.

Comments are closed.