XML File for City Build List?

Flak Fox

Radioactive Vulpine
Joined
Apr 10, 2004
Messages
260
Location
USA
I'm wondering if anyone's found a file that orders the units in a city's build list?

I attempted to modify the ID of units manually, thinking maybe that'd have an effect but it didn't.

Reason for asking is a mod I'm working on adds new units, but always throws them down at the bottom of the build list. I'd like them to be closer to units in their same class/domain.

Any posts would be appreciated, thanks in advance.
 
Ah, I think the same happens with new civs. Custom civs and even Babylon (DLC) appear at the bottom of the list during game setup, instead of being sorted alphabetically.

No idea why that happens.
 
Maybe try moving them around in the XML - it could be ordered by the order they are added to the database..
 
I'd assume it's based on ID.

Every building, unit, technology, etc. is assigned an ID number starting at 0. In most of the files, you don't see this declared after the first entry, and the code apparently just assumes that if the first one is ID=0, then the second must be ID=1 and so on down the line. And that means that all the new stuff you're adding is automatically getting assigned ID=(n+1) and up, because 0-N is being used for the existing items.
So I'd think that the only way to fix this would be to manually set the ID values of EVERY building, unit, etc. that is already in the game to be higher than it would be otherwise, to make a gap for your new items to go into; you can't just set, say, "ID=17" for one of your new units, because there'd already be a unit with ID of 17 in the database; you'd want to change whatever has 17 already to be at 18, and so on up the line. Obviously this is a lot of work, and definitely not very compatible with other mods. (This also seems to imply that if you're making a mod that replaces certain base units with different ones, that you should delete the old units and such BEFORE adding the new ones.)
I ran into this in my future mod, but it's not so bad there because most of the existing units will become obsolete at various points and keep the list of possible build items short.
 
Sadly it's not based on ID or placement in the XML code, tried both.

Manually setting the ID higher MIGHT work, but to test it, I set worker to 0 and settler to 1, settler still remained above worker in game, so...
 
Found it. It's not in the XML.

It's in UI/InGame/Popups/ProductionPopup.lua, and the logic is just

for unit in GameInfo.Units() do
(stuff, including a test to see if this particular unit is buildable in the current era)
end
then the same loop for Projects,
then for Buildings,
and finally for Processes (Wealth, Research)

So it looks like it'll just take the order of everything in that file, period, in the order they appear in the file. Anything you add to the file would, of course, be placed at the end of each particular list, so it's not using ID or anything.
You'd have to remove every unit and building in the game, then add the official lists back in as-is but with your units inserted. Probably not worth it.
 
Probably not worth it indeed, but it still might be worth looking into.
 
Found it. It's not in the XML.

It's in UI/InGame/Popups/ProductionPopup.lua, and the logic is just

for unit in GameInfo.Units() do
(stuff, including a test to see if this particular unit is buildable in the current era)
end
then the same loop for Projects,
then for Buildings,
and finally for Processes (Wealth, Research)

So it looks like it'll just take the order of everything in that file, period, in the order they appear in the file. Anything you add to the file would, of course, be placed at the end of each particular list, so it's not using ID or anything.
You'd have to remove every unit and building in the game, then add the official lists back in as-is but with your units inserted. Probably not worth it.
You could, however, produce a more complex ProductionPopup.lua with that code replaced with more complex logic that orders by civilian/military, then domain, then something else (cost? existence or absence of some other flag?)

Alternatively, you could add a new table to the DB for production popup listing order, and have it order by that, and then put anything not included in that list in at the end, in natural order. Once mod associations are working, this would allow people to subsequently modify this table in their own mods, allowing for fine control of this ordering.

Personally, I'd go for the former option, but it'd create a little extra processing burden and would take some thought to determine the precise ordering. You could even offer multiple orderings, of course, and introduce a modular framework to add extra orderings through callbacks.
 
Back
Top Bottom