Pre-Order the Game!

Desura Digital Distribution

Monday, August 15, 2011

Galaxy Scripts implemented!

Spencer and I spent a lot of time working on this the past weekend, and I'm proud to say that it's successful! No more hard-coded galaxy generation code, it now runs off of scripts! So players can create their own galaxy shapes and plug it in the game if they so desire, or download other people's scripts.

How it works is that there are two required functions in the script. "GetVariables" and "Generate". GetVariables grabs a list of variables that the script will need for the game, along with which UI element to use (upDown, checkbox, slider, etc). The game then dynamically creates the UI for those variables. When the player've filled out the values (the script also provides default values), he can click on "Generate Galaxy". This calls the "Generate" function in the script, passing in the variables and their values. The script then return a list of points with which the game converts into galaxy data.

This is what the two functions look like:


When you select this script from the drop-down, it compiles and grabs the list of variables, then fills out the UI as shown here:



Yes, that's right, there's no player setup stuff. I've separated the Player and Galaxy setups into their own screens. And yes, that's a spiral galaxy! I've been trying to figure out how to create something like that, but gave up. Spencer pointed me to Spiral Formulaes (I didn't know the technical term used in generating galaxies in other games), and after some research, I was able to pull it off!

I'm still working on polishing and finishing this setup screen, but I think this is exciting for modders out there! AI will be similar to how this works, and the scripts will be in C#, so you can create your custom gameplay (galaxy shapes, races, AI, etc)!

5 comments:

  1. Nice idea but these return types are too weak typed for my taste. Dictionary(string, string) is passable but List(List(int)) is something that should done differently.

    Ideally galaxy script should be a class that implements following interface:

    interface IMapGenerator
    {
    public List(IGeneratorParam) GetVariables();
    public List(Star) Generate();
    //or List(StarParams) Generate();
    }

    Where class with parameters for UpDown control implements IGeneratorParam. But how to expose those interfaces and other classes to modder, I don't know. I'll do some research because I'll need something like that for DLL plugins.

    ReplyDelete
  2. That was the same problem that we faced. We couldn't figure out how to expose classes, so we went with what you saw in the post. It works pretty well, although it may be easier to make errors. If there's errors in compiling the script, it will show the errors so the modder can know what to fix.

    If you find a way to expose a certain class for modding purposes, let us know!

    ReplyDelete
  3. is there a playable demo yet?
    im following this project :)
    also i like the art style

    ReplyDelete
  4. Yes, there is a playable demo. To gain access to it, you need to pre-order it (donate at least $10). The money from preorders helps pay for the artwork which isn't free. The game's still under heavy development, so if you prefer to wait, that's fine.

    ReplyDelete
  5. hmm, maybe later. still like the project though :)

    ReplyDelete