Hi, I'm trying to make an UA that grants a yield modifier to a specific city based on how many outgoing international traderoutes it has. But I have some problems with the lua part, and would like a helping hand
This is my function to assign each "building" based on how many traderoutes goes out from the city:
and here is the function to get the amount of traderoutes in city:
Any help would be appreciated. Is it anything wrong with the logic? Or do I need something in addition to this?
This is my function to assign each "building" based on how many traderoutes goes out from the city:
Code:
local buildingTradeMod = GameInfoTypes["BUILDING_COU_NORWAY_TRADEMOD"]
function COU_Nortraship_TradeBonus(playerID)
local player = Players[playerID]
if (player:IsAlive() and player:GetCivilizationType() == civilizationID) then
for city in player:Cities() do
local numTradeRoutes = COU_GetNumInternationalTradeRoutes(playerID)
city:SetNumRealBuilding(buildingTradeMod, numTradeRoutes)
end
end
end
if isNorwayCivActive then
GameEvents.PlayerDoTurn.Add(COU_Nortraship_TradeBonus)
end
and here is the function to get the amount of traderoutes in city:
Code:
function COU_GetNumInternationalTradeRoutes(playerID)
local player = Players[playerID]
local numTradeRoutes = 0
local tradeRoutes = player:GetTradeRoutes()
for _, tradeRoute in ipairs(tradeRoutes) do
if (tradeRoute.FromCivilizationType ~= tradeRoute.ToCivilizationType) then
numTradeRoutes = numTradeRoutes + 1
end
end
return numTradeRoutes
end
Any help would be appreciated. Is it anything wrong with the logic? Or do I need something in addition to this?