PlotinusRedux
Warlord
- Joined
- Jul 11, 2013
- Messages
- 196
[Edit1]Added Suggested <LoadOrder> Convention[/Edit1]
Note--most mods won't have to worry about any of the below because they have no reason to care about load order. This information is really only necessary if you want to modify DLC content or the contents of other mods or you're working on a compatibility issue with another mod that could be resolved by altering load orders.
Default Order
The default load order of mods for new games is by ModRowId in mods.sqlite, which basically means mods are loaded in the order they were added to the database, with them being re-added any time the modified date of their .modinfo file changes.
When a saved game is loaded, however, mods load in alpha-numerical sort order by Mod Id--the GUID used as the "id" attribute in the root <Mod> element of the .modinfo file. If the last added Mod's id starts with "00", say, it will load last during game creation (since it was added last), but first when a game is reloaded, even before any DLC.
Basically, if your mod has load order dependent elements, don't rely on the default load order of mods--it may appear to work during your testing, but that's probably just because it's the last mod whose .modinfo you changed.
The default order of components is to load with their mods in the order in which they appear in it's .modinfo file.
The default order of files is to load with their components in the order in which they appear in the .modinfo's <Files> element, not in their order within the component. [Edit1]This default order seems rather kludgy, so I would suggest not relying on it as I wouldn't be surprised to see it change in the future, so I would suggest always using the Priority attribute (see below) to explicitly determine file order when order matters.[/Edit1]
Changing Mod Load Order
A mod will always load after any mods in its <Dependencies> list in .modinfo. However, you don't really want to use this unless unless your mod really requires the other mods to run.
There is also a <References> element which *should* force a mod to load after any mods listed there without actually requiring those mods like <Dependencies>, but it currently appears to be broken.
There currently is no reliable way to control the load order of mods. However--
Changing Component Load Order Across Mods
The <Properties> element of a component may contain a <LoadOrder>X</LoadOrder> element where X is a positive or negative integer acting globally across mods to determine the load order of the component, with lower numbers loading earlier. Thus, an <UpdateDatabase> with a <LoadOrder> of -1 will always load before the DLC content and any component of any mod that didn't specify a lower <LoadOrder>, regardless of the order the mods themselves load in. A <LoadOrder> of 1 would of course cause it to load after the DLC and any component of any other mod that didn't specify a load order.
So if you want to modify the units added by the DLC, just specify a <LoadOrder> >= 1 to make sure your component runs after the DLC components.
I've personally tested this with <UpdateDatabase>, <GameplayScripts>, and <ModArt>--it definitely works with the 1st 2, and definitely does not work with <ModArt>.
[Edit1]Suggested LoadOrder Conventions
I'll update this area as people offer better ideas or if there seems to be a consensus on a different system, but off the top of my head I'd suggest the following conventions for <LoadOrder> values:
(1) Make all your <LoadOrder> values multiples of 100, so if someone needs to slip in between the DLC and your mod or between 2 components of your mod they have room to do so;
(2) Split your <UpdateDatabase> stuff into 2 categories and put it in 2 different <UpdateDatabase> components:
(A) Stuff that is just adding/modifying/deleting individual units, buildings, etc.;
(B) Stuff that is meant to change all members of some category, like an UPDATE statement meant to change the movement of all light cavalry units.
For elements in (A), don't specify a <LoadOrder> unless you're operating on an individual item add by the DLC, in which case use a value < 10,000;
For elements in (B), specify a <LoadOrder> >= 10,100, to leave plenty of room beneath your component for other mods to add/delete/etc. things they would like your mod to affect.
(3) If you need to slip between the DLC and another Mod, 2 Mod components, etc., use the number half way between the 2 of them, to leave room for others that might need to slip between you and them latter.
[/Edit1]
Changing File Order Within Components
Under the <Items> element of any component, the <File> element may specify a Priority X like <File Priority="1">SomeFile</File>, which will determine the load order of the file within the component, overriding the order in the <Files> element off the root. X may be positive or negative, defaulting to 0 when not specified, and opposite of <LoadOrder>, higher numbers load earlier. The Priority has no effect on the same file in other Components or on the load order between components--it is strictly local to the <Items> element of the current component.
Changing Dep/ArtDef Load Order
Unfortunately there's no good answer here yet. <LoadOrder> has no effect on the order of <ModArt> components.
I've currently found no better solution than the one @Gedemon is using with R.E.D, where he's made 3 separate mods: the base RED Mod, a RED for MoarUnits extension, and an RED for Polish DLC extension. For the extensions, to use the MoarUnits one as a an example, he is adding the base RED mod and the MoarUnits mod to <Dependencies> in .modinfo and adding MoarUnits.dep's GUID to the extensions <RequiredGameArtIDs> like so:
It's messy and ugly and requires a separate extension mod for each additional compatibility. Although note, this is only necessary in order to apply the R.E.D. look to the additional units in MoarUnits and the DLC--if you're just adding a new unit and an artdef for it, you won't have to worry about any of this (though @Gedemon will if your mod becomes popular).
Note--most mods won't have to worry about any of the below because they have no reason to care about load order. This information is really only necessary if you want to modify DLC content or the contents of other mods or you're working on a compatibility issue with another mod that could be resolved by altering load orders.
Default Order
The default load order of mods for new games is by ModRowId in mods.sqlite, which basically means mods are loaded in the order they were added to the database, with them being re-added any time the modified date of their .modinfo file changes.
When a saved game is loaded, however, mods load in alpha-numerical sort order by Mod Id--the GUID used as the "id" attribute in the root <Mod> element of the .modinfo file. If the last added Mod's id starts with "00", say, it will load last during game creation (since it was added last), but first when a game is reloaded, even before any DLC.
Basically, if your mod has load order dependent elements, don't rely on the default load order of mods--it may appear to work during your testing, but that's probably just because it's the last mod whose .modinfo you changed.
The default order of components is to load with their mods in the order in which they appear in it's .modinfo file.
The default order of files is to load with their components in the order in which they appear in the .modinfo's <Files> element, not in their order within the component. [Edit1]This default order seems rather kludgy, so I would suggest not relying on it as I wouldn't be surprised to see it change in the future, so I would suggest always using the Priority attribute (see below) to explicitly determine file order when order matters.[/Edit1]
Changing Mod Load Order
A mod will always load after any mods in its <Dependencies> list in .modinfo. However, you don't really want to use this unless unless your mod really requires the other mods to run.
There is also a <References> element which *should* force a mod to load after any mods listed there without actually requiring those mods like <Dependencies>, but it currently appears to be broken.
There currently is no reliable way to control the load order of mods. However--
Changing Component Load Order Across Mods
The <Properties> element of a component may contain a <LoadOrder>X</LoadOrder> element where X is a positive or negative integer acting globally across mods to determine the load order of the component, with lower numbers loading earlier. Thus, an <UpdateDatabase> with a <LoadOrder> of -1 will always load before the DLC content and any component of any mod that didn't specify a lower <LoadOrder>, regardless of the order the mods themselves load in. A <LoadOrder> of 1 would of course cause it to load after the DLC and any component of any other mod that didn't specify a load order.
So if you want to modify the units added by the DLC, just specify a <LoadOrder> >= 1 to make sure your component runs after the DLC components.
I've personally tested this with <UpdateDatabase>, <GameplayScripts>, and <ModArt>--it definitely works with the 1st 2, and definitely does not work with <ModArt>.
[Edit1]Suggested LoadOrder Conventions
I'll update this area as people offer better ideas or if there seems to be a consensus on a different system, but off the top of my head I'd suggest the following conventions for <LoadOrder> values:
(1) Make all your <LoadOrder> values multiples of 100, so if someone needs to slip in between the DLC and your mod or between 2 components of your mod they have room to do so;
(2) Split your <UpdateDatabase> stuff into 2 categories and put it in 2 different <UpdateDatabase> components:
(A) Stuff that is just adding/modifying/deleting individual units, buildings, etc.;
(B) Stuff that is meant to change all members of some category, like an UPDATE statement meant to change the movement of all light cavalry units.
For elements in (A), don't specify a <LoadOrder> unless you're operating on an individual item add by the DLC, in which case use a value < 10,000;
For elements in (B), specify a <LoadOrder> >= 10,100, to leave plenty of room beneath your component for other mods to add/delete/etc. things they would like your mod to affect.
(3) If you need to slip between the DLC and another Mod, 2 Mod components, etc., use the number half way between the 2 of them, to leave room for others that might need to slip between you and them latter.
[/Edit1]
Changing File Order Within Components
Under the <Items> element of any component, the <File> element may specify a Priority X like <File Priority="1">SomeFile</File>, which will determine the load order of the file within the component, overriding the order in the <Files> element off the root. X may be positive or negative, defaulting to 0 when not specified, and opposite of <LoadOrder>, higher numbers load earlier. The Priority has no effect on the same file in other Components or on the load order between components--it is strictly local to the <Items> element of the current component.
Changing Dep/ArtDef Load Order
Unfortunately there's no good answer here yet. <LoadOrder> has no effect on the order of <ModArt> components.
I've currently found no better solution than the one @Gedemon is using with R.E.D, where he's made 3 separate mods: the base RED Mod, a RED for MoarUnits extension, and an RED for Polish DLC extension. For the extensions, to use the MoarUnits one as a an example, he is adding the base RED mod and the MoarUnits mod to <Dependencies> in .modinfo and adding MoarUnits.dep's GUID to the extensions <RequiredGameArtIDs> like so:
Code:
<RequiredGameArtIDs>
<Element>
<name text="MoarUnits"/>
<id text="8342b98d-80c7-4002-87bb-419646bd9b54"/>
</Element>
</RequiredGameArtIDs>
It's messy and ugly and requires a separate extension mod for each additional compatibility. Although note, this is only necessary in order to apply the R.E.D. look to the additional units in MoarUnits and the DLC--if you're just adding a new unit and an artdef for it, you won't have to worry about any of this (though @Gedemon will if your mod becomes popular).
Last edited: