MouseyPounds
Prince
Is there an easy way to detect if a city is getting the railroad connection production bonus? The only way I've come up with so far is by searching the production tooltip text, which is far from ideal. Spoilered below is what I'm currently using (which actually detects the lack of a RR connection), with the relevant statement hilighted red.
I seriously hope there is a better way to do this but I didn't notice a relevant function on the Player or City object pages on the wiki. Any ideas?
Spoiler :
Code:
pPlayer = Players[Game.GetActivePlayer()]
pTeam = Teams[pPlayer:GetTeam()]
iNumUnconnected = 0
iNumNoProdBonus = 0
for c in pPlayer:Cities() do
if (c ~= nil and not c:IsCapital() and not pPlayer:IsCapitalConnectedToCity(c)) then
iNumUnconnected = iNumUnconnected + 1
print(string.format("%s is not connected to trade network.", c:GetName()))
end
-- There has to be a better way to do this....
sTooltip = c:GetYieldModifierTooltip(YieldTypes.YIELD_PRODUCTION)
if (c ~= nil and not c:IsCapital() and [COLOR="Red"]string.find(sTooltip,Locale.ConvertTextKey("TXT_KEY_PRODMOD_RAILROAD_CONNECTION",GameDefines.INDUSTRIAL_ROUTE_PRODUCTION_MOD),1,true) == nil)[/COLOR] then
iNumNoProdBonus = iNumNoProdBonus + 1
print(string.format("%s does not have a railroad connection.", c:GetName()))
end
end
if (iNumUnconnected > 0) then
print(string.format("There are %d cities without a trade connection",iNumUnconnected))
else
print("All cities are connected!")
end
if (iNumNoProdBonus > 0) then
print(string.format("There are %d cities without a railroad connection",iNumNoProdBonus))
else
print("All cities have railroad connections!")
end
I seriously hope there is a better way to do this but I didn't notice a relevant function on the Player or City object pages on the wiki. Any ideas?