My last post did say something about once a week, so here I am. I was away for most of the weekend, but did manage to work on Avalanche on and off for most of the day Sunday. I set up a project to test out the Lua api and got a few things hastily working, the main ones being linking to the Lua libraries, registering functions and being able to call a Lua function from C++, and vice versa. I realized I will need some sort of console window to enter Lua commands in realtime and kinda got lost down the rabbit hole setting up such a console using plain Win32. This felt way more painful than gui programming should be, but I powered through it and am pretty happy with the results. As with the Lua test project I created, the code is pretty ugly and relies on global variables and free functions floating all around, so my next goal will be to clean that stuff up and make each of those pieces a little more self contained.
I'm feeling like scripting in a game can be a slippery slope. If you don't draw a line somewhere between what you want to script and what you want to code, you might end up with a game completely written in Lua. I'm going to err on the side of caution, and initially only expose things that will help speed up development to the scripting system. My plan is to write some reusable code to mainly allow for setting shader variables through my console, and to use that in picking up where I left off with my sky rendering I started in XNA. Once that is all established, it shouldn't be too hard from there to write a script to control a day/night sequence.
Possibly tomorrow look for some more details of how I implemented the console window and maybe some ideas about encapsulating some of the interfacing with Lua.