Actions

Guide (Modding)

From Unofficial Stationeers Wiki

Revision as of 12:19, 20 October 2019 by Bloby (talk | contribs) (Created a basic guide to modding the game.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Stationeers allows players to mod the game in a variety of ways using only a text editor and (semi-optionally) an image editor. Moddable features include starting equipment, world conditions, and item recipes. On this page we will demonstrate how easy it is to make changes to the game.

File Structure

To be recognized as valid, a mod must follow a particular file structure. The game provides an example of this file structure with a helpful readme at [Installation Location]/Stationeers\rocketstation_Data\StreamingAssets\ExampleMod.zip. This reveals the following structure (some text copied from the readme):

  • [Mod Name]\ — named after the mod, contains all the mod files
    • About\ — Contains descriptive information about the mod.
      • About.xml — Your mod meta-data used when uploaded to the workshop and when displaying your mod in the workshop menu.
      • Preview.png — Preview image of your mod used in the in-game mod browser.
      • thumb.png — Preview image of your mod used in the Steam Workshop. MUST BE BELOW 1MB OR UPLOAD WILL FAIL.
    • Gamedata/ — A directory to contain the files that change the game.
      • Language/ — Contains localization files for representing strings in various languages.
        • english.xml — Maps any additional string variables you use into English.
        • [Other Languages].xml — Maps string variables into other languages you might like to support.
      • [Modded Files].xml — Various XML files to overwrite portions of the game's defaults.

About Files

You must provide three files in the About/ directory for your mod to work. The two images are used in the Workshop and in-game mod menu; if you don't want to bother with these, you can just copy the generic images from the example mod. The file About.xml requires slightly more customization. The best way to do this is to copy the example mod file (reproduced below) and edit the fields with a text editor: you will need to set the mod name, author name, version number, and a short description of the mod.

The example mod metadata file "About.xml":
<?xml version="1.0" encoding="utf-8"?>
<ModMetadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Name>StationeersExampleMod</Name>
  <Author>You!</Author>
  <Version>0.123456.78</Version>
  <Description>This mod serves to demonstrate the correct format of a custom mod folder for Stationeers.</Description>
</ModMetadata>

Game Data Files

This is where the real work of the mod takes place. Each xml file in this directory, upon loading, writes (potentially overwriting) the game data. The default data is found in [Installation Location]/Stationeers\rocketstation_Data\StreamingAssets\Data\, and currently contains 27 xml files, each of which may be modded. These are as follows, with files that may be of particular interest to modders in bold.

File Purpose
advancedFurnace Defines the recipes for the Advanced Furnace
arcfurnace Defines the time, energy, and products of smelting ingots in the Arc Furnace.
atmospherepresets Defines default atmospheric properties for the moon and Mars. Possibly deprecated? For modding, use worldsettings instead.
autolathe Defines the time, energy, and recipes for items in the Autolathe.
arcfurnace Defines the time required and products of processing ore in the Centrifuge.
chemistry Defines the time required and recipes for items from the Chemistry Station.
cooking Defines the time, energy, and recipes for items in the Microwave.
customtraders Defines new traders for the trading system. This file has no entries by default, but contains a commented-out example for modders.
DynamicObjectsFabricator Defines the recipes for dynamic objects, which currently is a very small set.
electronics Defines the time, energy, and recipes for items in the Electronics Printer.
fabricator Defines the time, energy, and recipes for items in the Fabricator.
furnace Defines the required reagents, pressure range, and temperature range for smelting in the Furnace.
gascanisters Defines recipes for creating various gas canisters, but it is unclear where these are used. Possibly deprecated?
ingots Defines a mapping of resource types to their respective ingots. It isn't clear what happens if this is modded.
mineables Defines a list of mineable ores to generate in the world, with their rarity (but larger means more ore), vein sizes, etc. Usually, this is overridden in worldsettings: possibly deprecated?
organicsprinter Defines the time, energy, and recipes for items in the Organics Printer.
paintmixer Defines the time, energy, and recipes for items in the Paint Mixer.
paints Defines alternative paint recipes in the Tool Manufactory. Presumably this is a placeholder while until the developers are happy with the paintmixer system?
PipeBender Defines the time, energy, and recipes for items in the Hydraulic Pipe Bender.
reagentgrinder Defines the time and recipes for items in the Reagent Processor
recycling While this appears to relate to the Recycler, the file contains no entries. Posisibly deprecated?
security Defines the time, energy, and recipes for items in the Security Printer
startconditions Defines the starting equipment at the beginning of the game, separated out by starting race.
terraingenerationpresets Defines default terrain features. For modding, probably use worldsettings instead.
toolmanufacturer Defines the time, energy, and recipes for items in the Tool Manufactory.
tradeables Defines the value of items in the trading system.
worldsettings Defines the atmospheric, terrain, and lighting properties (and much more) of worlds and allows the definition of new worlds.

Examples

World Conditions

Suppose you wish to make Mars more friendly to humans, by adding more oxygen and increasing the temperature. To do this, you can copy the example mod, change the name and description in About.xml, and delete the example entries in the GameData directory. Next, copy over the default worldsettings file into your mod and delete all of the planets except Mars (the planet we intend to modify). To change the atmosphere composition, locate the <AtmosphereComposition> tags, and increasing the <Quantity> of Oxygen to say, 20. If you want, you could also eliminate pollutants by deleting that entire <SpawnGas> section. To increase the temperature, find the <Kelvin> tags and adjust the <value> entries upward. Note that atmospheric temperature is defined by a set of fixed points to interpolate between; time is measured from 0 (dawn) to 1 (immediately before the subsequent dawn), with noon at 0.25 and midnight at 0.75.

The relevant sections of the code are as follows (click expand on the right):
    <AtmosphereComposition>
      <SpawnGas>
        <Type>CarbonDioxide</Type>
        <Quantity>8.656</Quantity>
        <Name>CarbonDioxide</Name>
      </SpawnGas>
      <SpawnGas>
        <Type>Nitrogen</Type>
        <Quantity>0.27</Quantity>
        <Name>Nitrogen</Name>
      </SpawnGas>
      <SpawnGas>
        <Type>Oxygen</Type>
        <Quantity>20</Quantity>
        <Name>Oxygen</Name>
      </SpawnGas>
      <SpawnGas>
        <Type>Pollutant</Type>
        <Quantity>0.05839586</Quantity>
        <Name>Pollutant</Name>
      </SpawnGas>
    </AtmosphereComposition>

    <Kelvin>
        <keys>
          <Keyframe>
            <time>0</time>
            <value>288.15</value>
            <inTangent>60</inTangent>
            <outTangent>60</outTangent>
            <tangentMode>34</tangentMode>
          </Keyframe>
          <Keyframe>
            <time>0.25</time>
            <value>293.15</value>
            <inTangent>-10</inTangent>
            <outTangent>-10</outTangent>
            <tangentMode>34</tangentMode>
          </Keyframe>
          <Keyframe>
            <time>0.5</time>
            <value>288.15</value>
            <inTangent>-192</inTangent>
            <outTangent>-192</outTangent>
            <tangentMode>34</tangentMode>
          </Keyframe>
          <Keyframe>
            <time>0.75</time>
            <value>278.15</value>
            <inTangent>10</inTangent>
            <outTangent>10</outTangent>
            <tangentMode>34</tangentMode>
          </Keyframe>
          <Keyframe>
            <time>1</time>
            <value>288.15</value>
            <inTangent>324</inTangent>
            <outTangent>324</outTangent>
            <tangentMode>34</tangentMode>
          </Keyframe>
        </keys>
        <preWrapMode>ClampForever</preWrapMode>
        <postWrapMode>ClampForever</postWrapMode>
    </Kelvin>    


Item Costs

For a second example, suppose you really like the Stationary Battery, but you hate having to make steel before you can produce them. You wish for them to cost no steel, but for balance you want them to cost more copper instead. To do this, copy the electronics.xml file into your mod Gamedata directory, and delete all the RecipeData entries except for ItemKitBattery (the recipe we want to modify). Then, adjust the cost entries directly.

The entire resulting file then looks like this (click expand on the right):
<?xml version="1.0" encoding="utf-8"?>
<GameData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ElectronicsPrinterRecipes>
    <RecipeData>
      <PrefabName>ItemKitBattery</PrefabName>
      <Recipe>
        <Time>5</Time>
        <Energy>100</Energy>
        <Iron>0</Iron>
        <Gold>20</Gold>
        <Carbon>0</Carbon>
        <Copper>40</Copper>
        <Steel>0</Steel>
        <Uranium>0</Uranium>       
        <Hydrocarbon>0</Hydrocarbon>
      </Recipe>    
    </RecipeData>  
  </ElectronicsPrinterRecipes>
</GameData>


Localization Files

These are a large list of "Key" and "Value" entries for translating internal strings to the appropriate language. In modding, you will only need to localize strings that you define yourself; this comes up most often in creating new planets, as the "Name" and "Description" fields both define such strings. You only need to do this for languages you intend to support. To generate this file for a mod, it is probably easiest to copy the existing default localization file, delete all the entries, and then add back in entries for your new string. To understand how localization works, here are examples for the constructed Arc Furnace (internal name "StructureArcFurnace") in two languages:

English:
<Record>
    <Key>StructureArcFurnace</Key>
    <Value>Arc Furnace</Value>
</Record>
French:
<Record>
    <Key>StructureArcFurnace</Key>
    <Value>Four à Arc</Value>
</Record>