Lua scripting progress

Feb 20, 2013 11:34


The Battlezone Lua scripting system now supports Save and Load so mission scripts can preserve state across a game save.

That lua-marshal library didn't work out the way I had hoped so I wrote my own simple functions to serialize and deserialize common Lua values. They support nil, booleans, numbers, strings, and tables but duplicate shared objects and lock up when confronted with cyclical references. I'll look at how lua-marshal handles those cases at some point but the current way should be adequate for now.

I have a fully working version of the first NSDF campaign mission ("Red Arrival") in script. I haven't checked the other missions yet to see what, if anything, they need.

Scripting in Lua again reminded me how error-prone the process is. Unlike statically-typed languages, it can't catch mistyped variable names or incorrect usage for you. ZeroBrane Studio's static analysis feature definitely helps, though.

Now I just have to figure out how to set up Lua debugging. Most remote debuggers need the luasocket library and not many debuggers support Lua 5.2. I tried using Decoda but Battlezone crashes when the debugger connects. (My lightuserdata shenannigans for game object handles may have something to do with that.)

lua, battlezone, programming

Previous post Next post
Up