A couple questions about how the mod manager works

Alrighty, a couple questions about how the mod manager handles the files.

  1. The files in the mod folder, are they used exclusively or do they combine with the existing files? What I mean is, for example, say I were to make a ranged.json and added 1 weapon. When I loaded that mod, would only that one weapon exist or would it just be added on top of the already existing weapons in ranged.json?

If they do combine, how do I prevent that to make only what I have in the mod folder be loaded? So, say I didn’t want any of the vanilla weapons, how would I parse them out? Or can I make it so it ONLY reads from my ranged.json?

  1. Does the mod folder that I am working with have to be structured just like the data folder, and is it only json files that can be loaded in the mod loader?

Like, can I just drop all the .json files into my mod folder or do I have to say which is which? Say I renamed my “ranged.json” to “example.json”, would I and if so how would I say that it is the “ranged.json”? And is it only .json files usable in the mod folder?

I recently just dropped a JSON with a vehicle in it into my vehicles folder and it seemed to add it in harmlessly. Not sure how much that helps you out though.

Clayton might have got banned, but i would still like to know how this works.

Me too. Please explain.

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 Is the mod manager functional? · Issue #5551 · CleverRaven/Cataclysm-DDA · GitHub

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.

^ Thanks for taking your time to explain it bevapdin.

One minor note I would like to add:

You can, and I would recommend this, put the modinfo.json file in a directory for the said mod under the mod folder. This will prevent the core game from automatically loading the mod data as core.

Thanks very much BevapDin. This thread should be stickied.

Agreed.