Hello,
I'm trying to code an event in Python, where I need to get a city's trading partners (cities), with no success.
From the API here (is that the most updated?) I can see that in CyCity there's a getTradeCity(i) function that supposedly gives me another city, which I understand is a trading partner (a city for which there is an active trade route). But when I use it I get nothing.
More precisely, my code in CvRandomEventInterface.py is:
So basically I'm taking the city the event took, and then picking a city's random trading partner, and asking for the coordinates X, Y of that partner. The problem is I get -1 and -1 for x and y. It's like tradecity is empty.... (tradecity.getName() for example returns nothing). The (event's) city instance is correct though, for I can access its data with no problems.
What am I doing wrong?
I've seen the getTradeCity function used in other codes (see here for example), so I assume it should work, but it doesn't for me.
Ideas?
Thanks
I'm trying to code an event in Python, where I need to get a city's trading partners (cities), with no success.
From the API here (is that the most updated?) I can see that in CyCity there's a getTradeCity(i) function that supposedly gives me another city, which I understand is a trading partner (a city for which there is an active trade route). But when I use it I get nothing.
More precisely, my code in CvRandomEventInterface.py is:
Code:
def CattleDifussion(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]
player = gc.getPlayer(kTriggeredData.ePlayer)
city = player.getCity(kTriggeredData.iCityId)
routes=city.getTradeRoutes()
random=gc.getGame().getSorenRandNum(routes,"")
tradecity = city.getTradeCity(random)
x=tradecity.getX()
y=tradecity.getY()
What am I doing wrong?
I've seen the getTradeCity function used in other codes (see here for example), so I assume it should work, but it doesn't for me.
Ideas?
Thanks