Modding Basics

From Cosmoteer Wiki
Jump to navigation Jump to search

Important File Locations

There are 3 important file locations that you need to be aware when you get started with modding:

  1. The location of the base game
  2. The location of Steam Workshop mods before they're enabled
  3. The location of mods on your computer

Base Game

The base game location is based on your specific install, but can usually be found here:

C:\Program Files (x86)\Steam\steamapps\common\Cosmoteer

Inside that is a Data directory that contains the rules files for the game. We will go over what exactly the rules files are later on, but one important directory in there is the "Standard Mods" folder. In there, you'll find the example mods provided by the base game install.

Steam Workshop Mods

Steam Workshop Mods are downloaded to the Steam Workshop cache before they're added to the game. If you want to look at a mod as an example for a certain idea you're trying to implement, it can be helpful to subscribe to one and see how it was done in order to compare that to what you want to do. You can look at the mod before enabling it in-game, and those mods are usually found in the following location (again, based on your specific install):

C:\Program Files (x86)\Steam\steamapps\workshop\content\799600

The 799600 number is the actual ID of the Cosmoteer Game on Steam. It's a little tricky to look at a specific mod since the sub-folders are all based on Steam IDs, but you can look the URL for the mod's Steam page in order to match the ID.

Cosmoteer Mods

Once a mod is enabled in the game, it will appear in the following directory:

C:\Users\<username>\Saved Games\Cosmoteer\<SteamID>\Mods

Note that the there are two special path names there: <username> and <SteamID>.

<username> is the actual username you use for your computer.

<SteamID> is your specific user ID, so it will be different for your installation. Your best bet is to go into the parent folder and then go to your SteamID manually.

Your Own Mod Location

When working on your own mod, you can create a new folder in the "C:\Users\<username>\Saved Games\Cosmoteer\<SteamID>\Mods" folder and then put your mod.rules file in there. A good way to start is to copy over the mod.rules file from "C:\Program Files (x86)\Steam\steamapps\common\Cosmoteer\Standard Mods\example_mod\" folder into your mod directory.

The Rules File

The .rules files are basically text files with a different extension. For Windows, if you haven't already, you really should turn on showing filename extensions.

The contents of the rules file provides the definition of your mod and the specific actions you want to take. The mod.rules from the example_mod is well commented, so you can refer to that as a template.


The Header contains the following fields:

mod.rules header
Property Syntax Optional Description
ID ID = author_name.mod_name N Every mod must have an ID that is used to uniquely identify the mod and differentiate it from other mods. In order to avoid ID conflicts with other mods, you *must* follow the "author_name.mod_name" format. Do *not* use "cosmoteer" as your author name -- that is reserved for official mods only!
Name Name = "My Mod Name" N You must give a human-readable name for your mod. This is what will be shown in the user interface.
Version Version = 1.0.0 Y The version of the mod that will be shown in the user interface.
CompatibleGameVersions CompatibleGameVersions = ["0.20.27"] N This is a list of Cosmoteer versions that this mod is known to be compatible with. If this mod is turned on and it isn't known to be compatible with the version of Cosmoteer that the player is running, a warning will be displayed. When upgrading the game, mods that aren't known to be compatible with the new version will also be automatically disabled.
ModifiesMultiplayer ModifiesMultiplayer = true Y This should be set to true for any mod that makes gameplay changes that could affect multiplayer games. Setting this to false *MAY* make it possible to play with someone else who doesn't have this mod, so long as this mod doesn't actually make any gameplay changes. (Setting this to false will *NOT* magically allow you to play with someone who doesn't have this mod; it will just make the error less informative.) If omitted, the default is true.
Author Author = "Your Name/Handle" Y The name of the mod creator(s) that will be shown in the user interface.
Logo Logo = "logo.png" Y A logo to display for your mod in the user interface. If you specify one, the logo.png file must be in the same directory as the mod.rules file.
Description Description = "Description here" Y A longer description of what your mod does to the game. See the example_mod mod.rules file for how to add multiple lines.
StringsFolder StringsFolder = "strings" Y Mods can define their own per-language string files. The values in a string file (such as en.rules) will add to and override any values in the base string file (such as Data\strings\en.rules). Each language supported should have its own string file named after the two-letter 639-1 language code for that language. Strings can also be used to provide in-game lore.


A quick aside on syntax.

Basic Syntax
Type Syntax Explanation
Arrays [] Arrays are enclosed in [] tags. As an example, all of the actions you do in a mod.rules file is enclosed in a [] pair, so it's an array.
Groups {} Groups are enclosed in {} tags. A group can contain single values, other groups, other arrays, or a mix.
Single Values = Single values are usually set by using "Name = Value"
Comments // or /* */ Comment lines begin with // or you can comment blocks out by enclosing them in /* and */


The primary way to modify the game is through "Actions".

Actions are little commands that modify the game's .rules files *after* they have been loaded into RAM. (The actual .rules files in the 'Data' folder are never modified and so disabling a mod will cause the game to revert back to its vanilla state.)

First, the game loads the vanilla .rules files normally. Then, for every mod that is enabled, that mod's "actions" are run on top of the loaded .rules files, modifying them.

Using this technique, mods can make almost any change to the game that *could* be made by modifying the .rules files directly, but without actually having to make any permanent changes to the game files.

There are a small number of .rules files that can't be modified using actions. The most prominent example is the language string files (such as en.rules) which are modified using the StringsFolder setting above.

Add Add a data field to an existing [] list or to a named data field.
AddMany This is similar to the Add action but it can be used to add multiple data fields to a single [] list, but it can't add named data fields. The Overrides Action should be used to add multiple named data fields.
AddBase The "AddBase" action adds a reference to the inheritance list of an existing {} group or [] list.
Replace The "Replace" action changes a vanilla data field to a modded data field. This works with single values (like below), but you can also replace entire {} groups, [] lists, and file references as well.
Overrides The "Overrides" action allows multiple named data fields to be modified, or new named fields to be added. Note that Overrides can only be used on named data fields inside a file or {} group. For unnamed data fields inside a [] group, use the "Replace" Action.
Remove The "Remove" action deletes a vanilla data field from the game data. Note that if the removed data field has any dependencies you may get crashing errors.
RemoveMany The "RemoveMany" action is just like the "Remove" action, but it allows you to remove multiple data fields without having to create a separate action for each data field you want to remove.