There are some things that you just can’t do with merely a tag tree. Things would just become too damn hairy that way! Now, I had planned to have towns and such be predefined, with perhaps a bit of random variation – say, placing a building on another spot, moving all the things inside with it, and having semi-important characters rolled up randomly like any other encounter – and it’s exactly those semi-important characters that could really use a proper scripting method!
I talked about this on IRC yesterday and though I won’t name the other guy, he was all “why reinvent the wheel when you’re writing this game in C# and have a full compiler right there?”
First of all, using CodeDOM and such to compile and run arbitrary code simply won’t do because of a bunch of important limitations. These include that the code block must be contained in at least one method, in turn contained in a class, in a namespace. You could make the script system assume the wrapper class but that doesn’t solve the other problem: everything must be a method call on an object.
this.Wait(20); //mind you, other entities should still run.
this.Character = (char)0x42;
Second, you can’t easily have a script repeat itself. Imagine a character who constantly (that is, until interrupted) checks a readout, looks surprised, moves a small distance towards a control panel, waits a bit (to tweak the controls) then moves back to the readout and repeats. Sure, it can be done, but it won’t be pretty.
“So why not use something else like Lua?” you might ask. Because it has many of the same or similar problems, when you think about it. That, and some personal problems that go beyond scope.
Noxico takes after Megazeux, and MZX’s Robotic language may have problems of its own, but it works. For the early games like Caverns of Zeux and Cans, Robotic was perfectly suitable.
It’s easy enough for me to write a reasonably suitable scripting engine for Noxico. The big problems I see are with conditionals and loops, and even then I have a good idea how to do it, without getting a full and proper parse tree involved and still support nested ifs! No trees, just a simple list of script lines, one command per line.
move up //or north…
char 0x42 //or ‘B’ or 100…
Reinventing the wheel seems like a pretty good idea, really. Especially when you need a bicycle wheel and all the off-the-shelf ones are for SUVs.