Actions
Feel free to contribute and don't worry about perfection - other editors can make corrections if necessary. Just get creating!
Actions are the primary way to modify the game.
They are little commands that modify the game's .rules
files after they have been loaded into memory. The actual .rules
files in the Data
folder are never modified, allowing for switching mods on and off without a risk of breaking the vanilla .rules
.
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 (following the mod loading order), modifying them in memory.
Using this technique, mods can make practically 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.
- Modding basics: mod locations, example mod,
.rules
syntax. - Paths — to understand to which files the action relate to.
Action: Add — adds a new data fields
You can add | You cannot add | To where you can add it to? |
---|---|---|
|
.rules file (using string path)
|
Only if
|
Syntax
{
// [required: YES]
// The name of this action.
Action = Add
// [required: YES]
// A string path to a .rules file (without "&" modifier)
// or somewhere inside of it where to add the data.
//
// Value in <...> must be a string path to a .rules file, relative to the Cosmoteer's Data directory.
// Following it must be a path to a particular node inside the .rules file
// (which can be omited if you adding something to the .rules file itself and not a particular node).
AddTo = "<builtin_ships/builtins.rules>/Ships"
// [required: no]
// If "true", the "AddTo" will be created if it doesn't exist instead of giving an error.
// Default is "false".
CreateIfNotExisting = false
// [required: no]
// If "true", the action will do nothing if the "AddTo" doesn't exist instead of giving an error.
// Default is "false".
IgnoreIfNotExisting = false
// [required: no]
// If "true", the action will do nothing if the "Name" already exists instead of giving an error.
// Default is "false".
OnlyIfNotExisting = false
// [required: depends, see below]
// The name of the field to add.
// Only required when adding to .rules files (without going in) or groups {}.
Name = "Density"
// [required: YES]
// The data to add.
// Can be of any type: single values, lists [], groups {}, references &.
//
// Note that below are only the examples of possible values -
// the action can't actually have multiple fields with the same name.
// Example: group {}
ToAdd
{
File = "ships/Arclight.ship.png"
Faction = cabal
Tags = [combat]
Tier = 3
Difficulty = 2
}
// Example: single value
ToAdd = 3.0
// Example: list []
ToAdd
[
1,
2,
3
]
// Example: reference &
ToAdd = &<super_armor/super_armor.rules>/Part
}
Examples
Adding a new ship to spawnable Career mode ships
In the example_mod
, adds a new ship called «Arclight».
The ship is added to the list of built-in ships (which enables it to spawn naturally): AddTo = "<builtin_ships/builtins.rules>/Ships"
. The .rules
file is located under Cosmoteer/Data/builtin_ships
→ builtins.rules
.
Both CreateIfNotExisting = false
and IgnoreIfNotExisting = false
ensure that the ship will be added only to an existing list, and otherwise throw an error (e.g. if the file name changes):
CreateIfNotExisting
would create theAddTo
path (the nodeShips
inside thebuiltins.rules
) if set totrue
. It's set tofalse
, meaning the action will not add anything ifAddTo
path doesn't exist.IgnoreIfNotExisting
would skip this action (if set totrue
) instead of giving an error ifAddTo
path doesn't exist. It's set tofalse
, meaning the action will give an error ifAddTo
path doesn't exist and ifCreateIfNotExisting
is set tofalse
.
The data to add is in ToAdd
. You can look into any built-in ship (inside the builtin_ships
folder) to gather some understanding about what these fields mean and values they can be assigned.
.rules
file/node location: Cosmoteer/Standard Mods/example_mod/mod.rules
{
Action = Add
AddTo = "<builtin_ships/builtins.rules>/Ships"
CreateIfNotExisting = false
IgnoreIfNotExisting = false
ToAdd
{
File = "ships/Arclight.ship.png"
Faction = cabal
Tags = [combat]
Tier = 3
Difficulty = 2 // (Note: Difficulty is currently unused but may be used in the future, so you should still specify a difficulty between 1-3.)
}
}
Action: AddMany — adds multiple new data fields
You can add | You cannot add | To where you can add it to? |
---|---|---|
|
.rules files (using string path)
|
List []
|
Syntax
{
// [required: YES]
// The name of this action.
Action = AddMany
// [required: YES]
// A string path to a .rules file or somewhere inside of it where to add the data.
//
// Value in <...> must be a string path to a .rules file, relative to the Cosmoteer's Data directory.
// Following it, must be a path to a list node [] inside that .rules file.
AddTo = "<ships/terran/terran.rules>/Terran/Parts"
// [required: no]
// If "true", the "AddTo" will be created if it doesn't exist instead of giving an error.
// Default is "false".
CreateIfNotExisting = false
// [required: no]
// If "true", the action will do nothing if the "AddTo" doesn't exist instead of giving an error.
// Default is "false".
IgnoreIfNotExisting = false
// [required: YES]
// The data to add.
// Must be a list []. Values can be of a particular type
// (single values, lists [], groups {}, references &) or
// mixed (e.g. [a single value, a group]).
// Note that below are only the examples of possible values -
// the action can't actually have multiple fields with the same name.
// Example: file references (using "&" modifier)
ToAdd = [
&<super_armor/super_armor.rules>/Part,
&<super_armor_2x1/super_armor_2x1.rules>/Part
]
// Example: single values
ManyToAdd = [
3.0
]
// Example: list []
ToAdd
[
[2, 3],
[5, [ Foo: "bar" ]],
]
// Example: group {}
ToAdd
[
{
File = "ships/Arclight.ship.png"
Faction = cabal
Tags = [combat]
Tier = 3
Difficulty = 2
},
{
File = "ships/SuperCoolShip.ship.png"
Faction = monolith
Tags = [combat]
Tier = 7
Difficulty = 3
},
]
// Example: mixed
ToAdd = [
3.0,
[2, 3],
{
File = "ships/Arclight.ship.png"
Faction = cabal
Tags = [combat]
Tier = 3
Difficulty = 2
},
&<super_armor/super_armor.rules>/Part,
]
}
Action: AddBase — adds a new reference to the inheritance list of a data field
Presumably, this is the Action to use when you want to make something inherit from something else.(clarification needed)[1]
You can add | You cannot add | To where you can add it to? |
---|---|---|
|
|
|
Syntax
{
// [required: YES]
// The name of this action.
Action = AddBase
// [required: YES]
// A string path to a list [] or a group {} to the inheritance list of which to add.
//
// Value in <...> must be a string path to a .rules file, relative to the Cosmoteer's Data directory.
// Following it, must be a path to a list [] or a group {} node inside that .rules file.
AddBaseTo = "<ships/terran/control_room_small/control_room_small.rules>/Part/Components"
// [required: no]
// If "true", the action will do nothing if the "AddBaseTo" doesn't exist instead of giving an error.
// Default is "false".
IgnoreIfNotExisting = false
// [required: YES]
// The data to add.
// Must be either a file reference, a group {} or a list [].
//
// Note that below are only the examples of possible values -
// the action can't actually have multiple fields with the same name.
// Example: file reference (using "&" modifier)
BaseToAdd = &<control_room_small_components.rules>
// Example: list []
BaseToAdd
[
1,
"hello",
]
// Example: group {}
BaseToAdd
{
File = "ships/Arclight.ship.png"
Faction = cabal
Tags = [combat]
Tier = 3
Difficulty = 2
}
}
Example mods
Action: Replace — replaces a data field
(clarification needed)[2]
You can replace | You cannot replace | With what you can replace it with? |
---|---|---|
|
|
|
Syntax
{
// [required: YES]
// The name of this action.
Action = Replace
// [required: YES]
// A string path to somewhere inside a .rules file (without "&" modifier).
//
// Value in <...> must be a string path to a .rules file, relative to the Cosmoteer's Data directory.
// Following it must be a path to a particular node inside that .rules file.
Replace = "<modes/career/career.rules>/EconDifficultyLevels/1/StartingMoney"
// [required: no]
// If "true", the action will do nothing if the "Replace" doesn't exist instead of giving an error.
// Default is "false".
IgnoreIfNotExisting = false
// [required: YES]
// The data to replace the data field in "Replace" with.
// Can be of any type: single value, list [], group {} or a reference &.
//
// Note that below are only the examples of possible values -
// the action can't actually have multiple fields with the same name.
// Example: single value
With = 12345.0
// Example: list []
With
[
1,
2,
3
]
// Example: group {}
With
{
File = "ships/Arclight.ship.png"
Faction = cabal
Tags = [combat]
Tier = 3
Difficulty = 2
}
// Example: reference &
With = &<super_armor/super_armor.rules>/Part/MaxHealth
}
Action: Overrides — modifies group {}
data field
You can modify | You cannot modify | With what you can modify it with? |
---|---|---|
|
|
|
Syntax
{
// [required: YES]
// The name of this action.
Action = Overrides
// [required: YES]
// A string path to a .rules file or somewhere inside of it where to add the data.
//
// Value in <...> must be a string path to a .rules file, relative to the Cosmoteer's Data directory.
// Following it, must be a path to a group node {} inside that .rules file.
OverrideIn = "<modes/career/career.rules>/EconDifficultyLevels/1"
// [required: no]
// If "true", the "OverrideIn" will be created if it doesn't exist instead of giving an error.
// Default is "false".
CreateIfNotExisting = false
// [required: no]
// If "true", the action will do nothing if the "OverrideIn" doesn't exist instead of giving an error.
// Default is "false".
IgnoreIfNotExisting = false
// [required: YES]
// The data fields to modify in "OverrideIn", along with their new values.
// Must be a group {}.
//
// Note that below are only the examples of possible values -
// the action can't actually have multiple fields with the same name.
// Example: single value
Overrides = {
// string
MoneyRewardFactor = "300%"
FameRewardFactor = "300%"
// number
StartingMoney = 100000
// whatever else
}
}
Action: Remove — removes a data field
You can remove | You cannot remove |
---|---|
|
(^^ clarification needed)[3]
|
Syntax
{
// [required: YES]
// The name of this action.
Action = Remove
// [required: YES]
// A string path to somewhere inside a .rules file (without "&" modifier).
//
// Value in <...> must be a string path to a .rules file, relative to the Cosmoteer's Data directory.
// Following it must be a path to a particular node inside that .rules file.
Remove = "<ships/terran/reactor_small/reactor_small.rules>/Part/Components/DestroyedEffects/HitEffects"
// [required: no]
// If "true", the action will do nothing if the "Remove" doesn't exist instead of giving an error.
// Default is "false".
IgnoreIfNotExisting = false
}
Action: RemoveMany — removes multiple data fields
You can remove | You cannot remove |
---|---|
|
(^^ clarification needed)[4]
|
Syntax
{
// [required: YES]
// The name of this action.
Action = RemoveMany
// [required: no]
// If "true", the action will do nothing if the "Remove" doesn't exist instead of giving an error.
// Default is "false".
IgnoreIfNotExisting = false
// [required: YES]
// A list of string paths all leading to somewhere inside a .rules file (without "&" modifier).
//
// Value in <...> must be a string path to a .rules file, relative to the Cosmoteer's Data directory.
// Following it must be a path to a particular node inside that .rules file.
RemoveMany
[
"<ships/terran/cannon_med/cannon_med.rules>/Part/Components/CommandConsumer"
"<ships/terran/cannon_large/cannon_large.rules>/Part/Components/CommandConsumer"
"<ships/terran/railgun_loader/railgun_loader.rules>/Part/Components/CommandConsumer"
"<ships/terran/railgun_accelerator/railgun_accelerator.rules>/Part/Components/CommandConsumer"
"<ships/terran/railgun_launcher/railgun_launcher.rules>/Part/Components/CommandConsumer"
]
}
Actions targeting other mods
It is possible to modify what other mods do or contain via your own mod. That's one way to interact with content that you don't integrate into your own mod (for legal reasons for example).
However it's not possible to directly modify what the Actions in another mod do[5]. You can still remove anything an Action added, for example.
- ↑ clarification needed: what happens if the action adds to an inheritance list of a node that doesn't inherit from anything?
- ↑ clarification needed: can a file be replaced?
- ↑ ^^ clarification needed: does this doesn't work?
- ↑ ^^ clarification needed: does this doesn't work?
- ↑ https://discord.com/channels/314103695568666625/368422988753928193/1228049113405456456