Lachlan's misadventures in games programming

Saturday, 8 October 2011

Platform Progress - Scripts Ahoy!

10/08/2011 12:12:00 pm Posted by Lachlan No comments

I've started the process of being able to load scripts from files and (am working towards at the moment), saving them to files. As of Thursday, it loads (most of) the keyboard configuration from a script file. This script file, actually:

FatController bind_wing_keys K_LEFT "Actor inst 100" K_RIGHT "Actor inst 101" "Actor inst 102"
FatController bind_key_down K_SPACE "Actor inst 103"
FatController bind_key_up K_SPACE "Actor inst 104"
FatController bind_key_down K_ESCAPE "Game quit_signal"
FatController bind_key_down K_BACKQUOTE "Game toggle_console"
FatController bind_key_down K_e "Game toggle_editor"

This is important for a couple of reasons. The primary one is that levels are to be saved as a script which contains instructions on building levels - I've got recipe's being generated already, now I'm ensuring that I can save them.

The first step of this project was adjusting the PuppetMaster's Process Command thing to take multiple commands by splitting it by newlines and semicolons (though, in the case of the latter, providing that they're not within double-quote marks). I decided to use the same method I have for actually processing commands -  using an overly complex RegEx command that I barely understand, as processed by boost::regex.  The RegEx function I ended up using is:
"(\\.|[^\"])*\"|[^\n;]+

The sad thing is, I'm not entirely certain how this works except it does when I run it through "The RegEx Coach" (excellent piece of software btw). In reality though, RegEx seems to me to be a return to the archaic language of APL (see Wikipedia to see why I make this comparison). It's an ol' APL proverb that:
'Tis every programmers goal in life
Before his race is run
To write three lines of APL
And make the damned thing run!'

0 comments:

Post a Comment