(Solved) A question about xml inheritance between files

Started by herrcaptain, March 02, 2015, 08:04:34 PM

Previous topic - Next topic

herrcaptain

Sorry if this is a dumb question (or more accurately, questions), but I just want to make sure that I'm understanding things correctly and can't seem to find the answers elsewhere.

Basically, I've recently started compiling a modpack that contains several other mods and then tweaks them. I've structured this by leaving the original packs untouched and then (with my own mod at the bottom of the load order) changing anything necessary within my own mod. For instance, if one of the packs adds a weapon that I need to modify to work with another pack's weapons, I create a copy of it in my own mod and edit it from there.

If I'm understanding this correctly, my changes will essentially overwrite the thingdef from the mods higher up in the load order. Correct?

Assuming that is true, what is the best approach to take if two or more mods have conflicting definitions for the same parent item?

For instance, two of the mods that I am including in my pack have slightly different definitions for the BaseGun thingdef. When Rimworld actually loads the mods into memory upon initializing them, will the BaseGun definition from the mod that is loaded later also affect the instance that was loaded earlier - essentially overwriting it? That would seem to make sense, but given that thingdef parents don't seem to inherit through separate xml files I could also see it going the other way when dealing with parent items. As in, as each xml file is processed upon loading the game it just looks within each individual xml file to build the stats for each item or thing.

Basically, what I'm getting at is that in a situation like this will I need to manually rewrite/rename one of the parent definitions if each BaseGun instance actually needs to have different stats, or is it enough that they are located in separate xml files?

Does this even make sense?  :-X

herrcaptain

Actually, I seem to have managed to figure this out myself. I created a separate xml file with its own definitions for BaseGun, BaseHumanGun (still inheriting BaseGun as normal), and a test weapon that inherited BaseHumanGun. As a test I changed the flammability of BaseGun to 0 for this xml file and loaded it alongside the other mods. The test weapon had a flammability of 0% as expected, and all of the other weapons retained their usual flammability of 100%.

So, to answer my own question from moments ago, it seems that the parent definitions are calculated separately for each xml file and only the last definition in the chain overwrites others with the same name.

If I'm still missing something or anyone has any further insight I'm all ears, otherwise it looks like I worked it out.

StorymasterQ

That sounds about right. That's also what's causing most, if not all, of mod incompatibilities. One mod overwriting what other mods have overwritten.
I like how this game can result in quotes that would be quite unnerving when said in public, out of context. - Myself

The dubious quotes list is now public. See it here

herrcaptain

Yeah, that's what I figured so I've been going through my modpack piece by piece and checking for incompatibilities before adding new mods into the mix. It's tedious but it's for the best.