Identifying Improvement Type

ww2commander

Emperor
Joined
Aug 23, 2003
Messages
1,243
Location
Australia
Anyone know how to convert GetImprovementType to determine if an improvement is a 'trading post'?

I am still learning so this question might be easy but I cant figure it out.

Thanks for any help.
 
It should be something like:
Code:
plot:GetImprovementType() == GameInfo.Improvements["IMPROVEMENT_TRADING_POST"].ID

There are several other options. The simplest is
if ( plot:GetImprovementType() == GameInfoTypes.IMPROVEMENT_TRADING_POST ) then
That's really the best syntax when you're hard-coding which improvement type does what, instead of dynamically checking as you go. The GameInfoTypes method can be used for any table that has an ID field, since that's what it returns.

The way Androrc suggested is a bit longer, but has the advantage that you can replace the "IMPROVEMENT_TRADING_POST" part with a text string variable that can be changed as the conditions demand. Maybe you want this logic to apply for any Improvement that adds Gold, for instance.

Beyond that, the other methods' desirability heavily depends on what you intend to use the information FOR. If you're going to be checking multiple hexes then it might be better to do it one way, while if you're going to want to use other information about the Trading Post once the hex is located, you might do something different. And it'll also depend on whether this is only supposed to apply to one player or if it's a worldwide thing (modifying all Trading Posts in the world at once).
 
Thank you for the very quick response. :goodjob:

Hard coding is ok as I am using this for a specific scenario map. Need a way to label specific hex coordinates with town names to cut down on the number of cities a player needs to manage.

If the population does not meet a certain threshold then I will represent the town using the trading post improvement and then provide the town name via the mouse over popup using LUA.
 
Back
Top Bottom