InfraSpace Modding Tutorial: Changing existing parameters

This short tutorial goes into depth on how to easily change the configurations in the games .json files, as done in the “Making your first example mod” Tutorial . Go through that tutorial first.

At the time of writing, the following internal configuration files can be changed by using patches:

  • buildings.json contains definitions for all kinds of nodes in the game including buildings and intersections
  • constructionCategories.json contains definitions for the bottom menu from where you can select the different buildings to build
  • resources.json contains definitions for all the resources that can be gathered or created in the game
  • roads.json contains definitions for all the types of roads that can be placed
  • spaceshipModules.json contains definitions for the spaceship repair modules and their requirements
  • techs.json contains definition for the technology tree and the research requirements
  • localization.json contains all the text translations in the game
  • gameConfig.json all kinds of parameters that control gameplay, balancing, and more

For creating patches, it’s important to know the structure of these .json files. That’s why you can export them straight from the game. On the Mods screen you can see an “Export Config Files” that will create a folder on your desktop and put all relevant configuration files in there.

Also the ISModKit contains some example patches in the SaltMine example mod pasted here for your convenienve:

{
	 "replaceOperations": {
		  "buildings/basicFarm/productionLogic/productionDefinition/consumables": [
            {"resourceName": "salt", "amount": 1 }
          ],
          "constructionCategories/categories/9/children": [
            {"itemName": "recyclingCenter"},
            {"itemName": "soilEnrichmentFacility"},
            {"itemName": "targetingStation"},
            {"itemName": "infiniteProducer"},
            {"itemName": "infiniteConsumer"},
          ]
	},
	"removeOperations": [
          "buildings/largeSandMine",
          "constructionCategories/categories/4/children/1/children/2",
          "constructionCategories/categories/4/children/1/children/1"
	]
}

Find the up-to-date file here.

The patch file modifies the json files of the base game or the json files of any mods before giving them to the game to process. It was designed to be as self-explantory as possible:

  • replaceOperations replaces values with whatever you put on the right side of the statement
  • removeOperations remove complete elements. Often, this means that the game’s default values are used instead, for example if you delete buildings/sandMine/productionLogic/productionDefinition/powerNeeded, the game will just use a default value.
  • However, if you delete complete objects, like buildings/sandMine or resources/sulfur, they will not be accessible in the game. This can lead to bugs though.
  • The first word of any path is always the file that’s being modified. The rest of the path navigates through the json structure.
  • You don’t need to replace single values, feel free to replace full objects.
  • You can access elements of a JSON array by indexing (0-based numbering). For example in the above code snippet we have "constructionCategories/categories/9/children" which means that we want to replace the children of the 9th category. If you look at constructionCategories.json you will see that the 9th element of categories JSON array is the miscellaneous category.
  • While doing removeOperations with JSON arrays, make sure to remove array elements in reverse order. For example if you look at the example code snippet above, you can see that first the 2nd element is removed and then the 1st element is removed.
2 Likes