Iceco
Warlord
- Joined
- Oct 27, 2010
- Messages
- 188
I'm trying to make a mod that gives XP to garrisoned units (with various conditions to it). This is the Lua mod I've attempted.
However, I'm currently stuck trying to make the script go through all players (major and minor civs), so I can then go through their cities and check if there's a garrison in it.
The problem is finding or compiling the list of active (major and minor) civilizations and getting their ID (the ID in the Game, not in GameInfo.Civilizations) and/or that of their cities.
I think I got it working for just the major civs
This returned the same value for every city, but did give the different names when I did city:GetName(), so I'll probably be able to work with this code (and replace the 'print' statement with whatever will be necessary).
For the city states I got this far: (I made it print out a bunch of things to make it more readable and to better find out what could be wrong.)
There are a number of things wrong with this: firstly, obviously the presence of major civ city names at the end (the correct ones though), secondly the number of entries (there are 8 minor civs in-game) and then pretty much all Type entries. Surprisingly, the 6 listed names of city-state cities are correct, but there are 2 missing: Florence and Vienna.
So what do I need to change? Or maybe it's possible to do it without splitting things up between major and minor civs? Any help would be appreciated.
However, I'm currently stuck trying to make the script go through all players (major and minor civs), so I can then go through their cities and check if there's a garrison in it.
The problem is finding or compiling the list of active (major and minor) civilizations and getting their ID (the ID in the Game, not in GameInfo.Civilizations) and/or that of their cities.
I think I got it working for just the major civs
Code:
Code:
> for civilization in GameInfo.Civilizations() do
> for city in Players[civilization.ID]:Cities() do
> print (
> Players[civilization.ID]:GetID(),
> city:GetID()
> )
> end
> end
Return:
WorldView: 0 8192
WorldView: 1 8192
WorldView: 2 8192
WorldView: 3 8192
For the city states I got this far: (I made it print out a bunch of things to make it more readable and to better find out what could be wrong.)
Code:
Code:
> for minor in GameInfo.MinorCivilizations() do
> for city in Players[minor.ID]:Cities() do
> print(
> "CIV:",
> Players[minor.ID]:GetID(),
> GameInfo.MinorCivilizations[Players[minor.ID]:GetCivilizationType()].Type,
> "CITY:",
> city:GetID(),
> city:GetName()
> )
> end
> end
Return:
WorldView: CIV: 0 MINOR_CIV_VENICE CITY: 8192 Thebes
WorldView: CIV: 1 MINOR_CIV_BRUSSELS CITY: 8192 Sukhothai
WorldView: CIV: 2 MINOR_CIV_LHASA CITY: 8192 Karakorum
WorldView: CIV: 3 MINOR_CIV_BELGRADE CITY: 8192 Rome
WorldView: CIV: 22 MINOR_CIV_SEOUL CITY: 8192 Hanoi
WorldView: CIV: 23 MINOR_CIV_SEOUL CITY: 8192 Helsinki
WorldView: CIV: 24 MINOR_CIV_SEOUL CITY: 8192 Lhasa
WorldView: CIV: 25 MINOR_CIV_SEOUL CITY: 8192 Geneva
WorldView: CIV: 26 MINOR_CIV_SEOUL CITY: 8192 Almaty
WorldView: CIV: 27 MINOR_CIV_SEOUL CITY: 8192 Monaco
So what do I need to change? Or maybe it's possible to do it without splitting things up between major and minor civs? Any help would be appreciated.