NatPat

  1. DCS – Dig Command Script

    Some of you may know that the workers in my game have ‘commands’ that they can execute, such as Mine Left, Walk To a point, etc.

    I was finding these rather difficult to work out how to code, as commands had to access other commands, and commands could report errors which would means I would somehow have to stop the previous command at a certain point. I was previously accomplishing it using a function where a command had ‘subCommands’.

    However, executing commands within commands within commands was horrible to do. I couldn’t think of an elegant solution that would allow me to break in and out of the commands at any time and also allows errors to stop a command in their tracks.

    So, I wrote my own little scripting language.

    It’s very assembly like. Which is always fun.

    Also, being a scripting language, it has all the advantages of being a scripting language, such as being editable at runtime (which is amazing).

    It’s been a fun learning experience, writing an interpreter/parser. (I’m going to say parser – it doesn’t feel good enough to be classified as an interpreter).

    So yeah. I can dip in and out, commands can execute other commands, and it’s awesome. The only problem is it’s quite hard to code in. Ah well, it gets the job done.

  2. No Comments

    Comments are now closed