The hierarchy is new in v50 and is exactly as you see in-game: mods are loaded in order, top to bottom. You can change the load order on save load. There are mod info tokens allowing you to force certain mods to be loaded before or after others. Raws within mods are loaded in alphabetical order. Nothing more to it than that.
When I was referring to the hierarchy, I had my macro lens on. Not file hierarchy, but hierarchy of tokens within one entry in the raw. For instance:
[PLANT:MUSHROOM_HELMET_PLUMP] --- Top level
[NAME:plump helmet][NAME_PLURAL:plump helmets][ADJ:plump helmet] --- 1st level subordinate to the top level
[USE_MATERIAL_TEMPLATE:STRUCTURAL:STRUCTURAL_PLANT_TEMPLATE] --- probably also 1st level sub
[MATERIAL_VALUE:2] --- 2nd level, subordinate to 1st level At least, I'm guessing that's true. If I wanted to change the MATERIAL_VALUE here, I'd need to know that it's "within" that material template. I'm just inferring that it is, since I can't find anything that explains the hierarchy. The indentation helps, but there are a lot of raws without any indentation, or with spacing that may or may not be indicative of something.
Also, the problems with bone trousers you're getting are explained on the wiki page:
Craftsmen can make this item from bones. Randomly generated outfits don't include bone armor.
Sorry that I wasn't clear. I'm not at all having a problem with bone armor not showing up in randomly generated outfits. Yes, I mentioned that it wasn't showing up, but just as a detail to confirm that the random outfit aspect is working as expected. The problem I'm having with bone trousers is that the game turns them into jagged bone greaves (or some combination of adjective + not the object it should be) when a save is loaded.
The problems with reloading the world causing off-by-one errors or whatever is probably due to CUT_X being done in the wrong order and thus duplicated raws (what y'all are calling "list shifting", it's been a known thing for years lol) happening, which is odd. Perhaps you're putting your mod before the vanilla items in the load order, which would cause obvious problems.
Obvious enough that even I figured out I should always load my mod last.
Here's something I used for testing. Feel free to fire it up, save, and load to see what happens to the caps:
item_helm
[OBJECT:ITEM]
[CUT_ITEM_HELM:ITEM_HELM_CAP]
[ITEM_HELM:ITEM_HELM_CAP]
[NAME:cap:caps]
[METAL_ARMOR_LEVELS]
[LAYER:OVER]
[COVERAGE:50]
[LAYER_SIZE:10]
[LAYER_PERMIT:15]
[MATERIAL_SIZE:1]
[SOFT]
[LEATHER]
[BARRED] - this has been added
[SCALED] - this has been added
[HARD]
[METAL]
[STRUCTURAL_ELASTICITY_WOVEN_THREAD]
[SHAPED]It actually works far better than what I expected, because it adds the option to make bone/shell caps to the appropriate menus in the appropriate workshop, without anything else required. I'm totally mystified as to why this causes such problems after the dwarves make the item and the game is loaded from a save.
What I've done to test this:
- First, I tried doing a SELECT_ITEM and then adding the two tokens. Didn't work at all, so switched to this CUT-and-replace method instead.
- New world. Activated this mod, no other mods. Last in load order.
- Build a butcher, craftdwarf 'shop, leather 'shop. Butcher a yak.
- Make a leather cap, and make a bone cap. Save and exit to main menu while the caps are easy for me to find again, in the workshops.
- Load the game, check the workshops. Each cap, both the bone and the leather cap, has been changed to a [adjective] + bone/leather + non-cap item (e.g. "rounded yak leather helm").
It's consistent and repeatable. Either I've done something wrong (not sure how, the item_helm.txt file is the only file in the objects folder), or I've discovered an unexpected behavior that is worth documenting.