View Full Version : A quick Python question


RogerBacon
Jan 01, 2006, 04:20 PM
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

Kael
Jan 01, 2006, 04:24 PM
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.

RogerBacon
Jan 01, 2006, 04:44 PM
Thank you very much. That worked nicely.

Roger Bacon