Mint building

Chiyu

Prince
Joined
Jun 9, 2006
Messages
412
Location
Limburg, The Netherlands
Hey guys, I'd like to have a building that can only be built as long as as a resource - in this case, Gold - is in the city's radius (as in Civ5, yes). I tried to copy and alter the code from Tsentom's code for the Great Mosque of Djenne, but I have no idea why it's not working as it should. If anyone could help me, I'd be grateful :).

Code:
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]

### Mint Start ###

		if ( eBuilding == gc.getInfoTypeForString("BUILDING_MINT") ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			bt_gold = gc.getInfoTypeForString( 'BONUS_GOLD' )

			for iXLoop in range(iX - 2, iX + 3, 1):
				for iYLoop in range(iY - 2, iY + 3, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(iPID)==true ):
						if ( pPlot.getTeam()==iTID ):
							if ( pPlot.getBonusType()==bt_gold ):
								return False
			return True

### Mint End ###
 
Did you enable the relevant callback in PythonCallbackDefines.xml?
You should use the value for USE_CANNOT_CONSTRUCT_CALLBACK to 1 for your function to be called.

In addition, you need the 'return True' in the end to be outside of the 'building is mint' condition (in the code you pasted it seems that it's inside the if clause, but it could be bad indentation copying).
 
Back
Top Bottom