A quick Python question

RogerBacon

King
Joined
Nov 16, 2003
Messages
649
I have
if pCity.hasBuilding(5):# 5 is barracks
*****CyInterface().addImmediateMessage(message2,"")
*****CvUtil.pyPrint(message2)

I would like to replace the '5' above with something a little more dynamic. Is there anyway to find out if a particular building exists in a city other than using its numeric index?

Roger Bacon

PS. Happy New Year
 
RogerBacon said:
I have
if pCity.hasBuilding(5):# 5 is barracks
*****CyInterface().addImmediateMessage(message2,"")
*****CvUtil.pyPrint(message2)

I would like to replace the '5' above with something a little more dynamic. Is there anyway to find out if a particular building exists in a city other than using its numeric index?

Roger Bacon

PS. Happy New Year

Replace 5 with: gc.getInfoTypeForString('BUILDING_BARRACKS')

That translates the human phrase into the index value. You may need to make that BUILDINGCLASS_BARRACKS depending on if the function wants the building object or the buildingclass object.
 
Back
Top Bottom