Number of Trade Routes

bane_

Howardianism High-Priest
Joined
Nov 27, 2013
Messages
1,559
I can't find in the API nor bc1's list of game events something that I can use to calculate the number of Trade routes emanating from a specific city. Anyone knows how to do it? I've been on this for some time now, researching both the forums and google but can't find an answer.

If from a specific city is not possible, I'll be content with just the amount of used trade route slots by a civilization.
 
There are very few trade route specific API methods. For most things you'll need to iterate one or all players trade routes and pull the data out of the trade route info table - lots of examples in TradeRouteOverview.lua

The basic iterator for one player's trade routes is

Code:
for _,v in ipairs(pPlayer:GetTradeRoutes()) do
  local pFromCity = v.FromCity
  local pToCity = v.ToCity
	
  -- Do something useful
end
 
Hmmmmmm... so if I wanted to, I could iterate through each player, and find out if they have a trade route ending a certain city?

I'd been considering a particular UB that would generate yields if trade routes connected to its city (via spawning dummy buildings), but from what I'd been able to find of the trade route lua I hadn't thought it'd be possible. If I can get this info from GetTradeRoutes(), that's awesome!
 
There is a lot of information in the table for each trade route

  • Domain
  • FromCivilizationType
  • FromID
  • FromCityName
  • FromCity
  • ToCivilizationType
  • ToID
  • ToCityName
  • ToCity
  • FromGPT
  • ToGPT
  • ToFood
  • ToProduction
  • FromScience
  • ToScience
  • ToReligion
  • ToPressure
  • FromReligion
  • FromPressure
  • FromTourism
  • ToTourism
  • TurnsLeft

And if using my DLL
  • TradeConnectionType
  • UnitID
  • IsRecalled
  • CircuitsCompleted
  • CircuitsToComplete
  • MovingForward
 
Back
Top Bottom