The mod manager works like this:
A mod must have an entry in a modinfo.json file, located in the data folder. (There may be several mods defined in one file, and there can be several of these files. They are all loaded anyway.)
A mod requires an ident and a mod-type (CORE or SUPPLEMENTAL), each world can only have one CORE mod, but many SUPPLEMENTAL mods, otherwise there is no difference.
Each mod has a data path. The game considers all files with the .json extension in that path (recursive) as part of the mod.
A simple example mod definition looks like this (contained in a modinfo.json):
{
"type": "MOD_INFO",
"mod-type": "SUPPLEMENTAL",
"ident": "self-contained-mod",
"name": "self-contained mod",
"description": "text...",
"path": "modinfo.json"
}
The path of a mod is defined like this:
-
If the mod info contains a path member, this is used and prefixed with the path of the modinfo.json that it is taken from (if read from a “data/mods/MyMod/modinfo.json” and path is “mod-data”, the path becomes “data/mods/MyMod/mod-data/”).
-
If the mod info does not contain a path member, the path becomes “/data” (if read from a “data/mods/MyMod/modinfo.json”, it will be “data/mods/MyMod/data/”).
Path can refer to a folder or to a json file itself (like in the above example). This allows self-contained mods, that consists of only one file. If the path refers to a single file and not a folder, only that file is used for the mod.
Each world gets a list of mods that are active for that world. The game loads the core data (everything in data/json) first, than data from each mod from the files described above. Changes to the original mods (in data/mods) will therefor appear in any existing world, as soon as the game is loaded.
The content of the mod can be nearly anything that is imported through json, look into the data/json folder to see what things are there. Everything not imported from json can not be modified.
The content of a mod overwrites any already defined content of the same id. This means a mod can define an item with the id “2x4” but with completely different properties than the original two by four (see data/json/items/melee.json for its original definition). This works for monster groups too, as described here https://github.com/CleverRaven/Cataclysm-DDA/issues/5551
One exception are item groups, they append to existing item groups. For example the item group “forest” contains stuff that randomly appears in forests. Add this to a mod:
{
"type" : "item_group",
"id" : "forest",
"items":[ ["toaster", 40] ]
}
makes toaster randomly appear, too. The other already defined items for that item group (rock, stick, berries) will still appear as well.
Combine with the core data and any other activated mod. The core data is always loaded first, the mods in the order they have been selected during the creation of the world.
Currently not possible. But one can move the core data (or part of it) to a special core mod and than not activate that mod.
Doesn’t matter, the file finder looks recursively for all files with the json-extension in the data path of the mod.
File names don’t matter (except for the file extension), and mod info is read only from files named exactly modinfo.json. One can name a file “blah.json” and put furniture, terrain, items, item groups, monsters into it.