This is what I've written:
The problem is while the pollution feature is successfully placed it's placed when any improvement is built, not just the ones I specified. Also, the feature never gets removed when a different improvement is built over top of the polluting one.
I guess the "if Improvement ==" line is always being evaluated as true but I cannot figure out why. Anyone have any insight?
Code:
def onImprovementBuilt(self, argsList):
'Improvement Built'
iImprovement, iX, iY = argsList
# BEGIN Pollution from Improvements
pPlot = CyMap().plot(iX,iY)
if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_MINE') or gc.getInfoTypeForString('IMPROVEMENT_QUARRY') or gc.getInfoTypeForString('IMPROVEMENT_WELL') or gc.getInfoTypeForString('IMPROVEMENT_OFFSHORE_PLATFORM'):
pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_POLLUTION'), 1)
elif pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_POLLUTION'):
pPlot.setFeatureType(-1, 1)
# END Pollution from Improvements
if (not self.__LOG_IMPROVEMENT):
return
CvUtil.pyPrint('Improvement %s was built at %d, %d'
%(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))
def onImprovementDestroyed(self, argsList):
'Improvement Destroyed'
iImprovement, iOwner, iX, iY = argsList
# BEGIN Pollution from Improvements
pPlot = CyMap().plot(iX,iY)
if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_MINE') or gc.getInfoTypeForString('IMPROVEMENT_QUARRY') or gc.getInfoTypeForString('IMPROVEMENT_WELL') or gc.getInfoTypeForString('IMPROVEMENT_OFFSHORE_PLATFORM'):
if pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_POLLUTION'):
pPlot.setFeatureType(-1, 1)
# END Pollution from Improvements
if (not self.__LOG_IMPROVEMENT):
return
CvUtil.pyPrint('Improvement %s was Destroyed at %d, %d'
%(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))
The problem is while the pollution feature is successfully placed it's placed when any improvement is built, not just the ones I specified. Also, the feature never gets removed when a different improvement is built over top of the polluting one.
I guess the "if Improvement ==" line is always being evaluated as true but I cannot figure out why. Anyone have any insight?