Creating Mods for High Frontier

Version 0.10 of High Frontier added support for “mods” — modifications that can be created, shared, and installed by players to change the behavior of a game.  We promised a few more words about that… so here we go!

First, we decided early on to support mods in High Frontier as much as possible.  That’s why we added them now, while the game is still in the very early stages of development, rather than trying to tack them on later.

However, earlier versions of High Frontier used the native binary file format that’s built into the .NET framework.  This turned out to be an unfortunate choice.  It was expedient, but fragile; it happened at least once that we added or changed something in the way colonies are represented, and older files became completely unreadable.  It’s possible to work around this, but doing so is difficult and expensive — that is, no longer expedient at all.

We knew we’d need some human-editable file format for mods, and since we were wrestling with the problems of .NET’s binary format anyway, we decided to reduce two problems to one, and select a convenient, text-based format for our own data as well as mod files.  We considered XML and JSON, the two industry standards for this sort of thing, as well as YAML and TOML, which are scrappy underdogs.  But we rejected each of these for one reason or another — none of them were as clean and simple as what we were looking for.

So we ended up defining our own format, which we call GRFON.  It’s inspired in part by the config file format used for KSP mods, so players who come from that community should feel right at home with it.  It’s incredibly easy to read and write.  Everything is a collection of values; a value may be either identified by a key word, or unkeyed, in which case it just forms a list with all the other unkeyed values.  That’s pretty much it!  Here’s an example.

title: Squawk Test 1
type: squawk
author: {
	name:	Joe Strout
	email:	support@highfrontier.com
	www:	http://HighFrontier.com
}
context: MainMenu

{
	when: RandomPercent < 50
	squawks: {
		This is a [cool|awesome|nifty|custom] squawk!
		Mods rock!
		[Making|Creating] mods is [crazy|super] fun!
		{ text: Is this [mod|thing] on?; icon: FaceWorried; user: ModMan }
	}
}

This file is in fact a complete HighFrontier mod, if saved with a name ending in “.hfmod” and stuffed into the Mods folder (details here).  You can see the key/value pairs, such as “type: squawk” (where “type” is the key and “squawk” is the value).  Simple values, like strings and numbers, appear right after the keyword and colon.  Complex values, i.e. values that are themselves collections, are enclosed in curly braces.  Values can either be one to a line, or you can have multiple values on one line, separated by semicolons.

You may think you see some additional syntax (square brackets) in the individual squawks in this example.  But that’s not part of the GRFON format; those are just part of the squawk values.  It’s the squawker itself that interprets those, after the GRFON file has been parsed.  This will be a fairly common pattern; since a value in a GRFON file can be pretty much anything, values in particular contexts may have additional syntax for whatever they represent.

We’re now using this GRFON file format not only for mods, but for our own files too, and we couldn’t be happier.  It’s easy to use, quick to read and write, and very backwards-compatible when something changes.  Keys are identified by name, so their order in the file doesn’t matter; and when a key is missing, we just fill in a default value.  Life is good.

(And yes, this means our game data is insecure — you could get in there and muck with it if you want.  So what?  It’s your game.  If hacking the data file increases your enjoyment, who are we to try and stop you?)

As for mods, so far, all you can do is add new squawks, either in the main menu feed or in Management mode.  But we expect to add support for many other types of mods in the future, including custom colony parts, buildings and decorations in internal management mode, and more.

So if you’re interested in modding High Frontier, have at it!  And let us know what support you need from us to make your ideas happen.