Hi,
In the spoiler is some of the code from one of my python events.
for movingBuilding in mobBuilding:
if pOnCity.getNumBuilding(movingBuilding)>0:
pOnCity.setNumRealBuilding((movingBuilding), 0)
pOffCity.setNumRealBuilding((movingBuilding), 1)
if movingBuilding == iSlums:
iRadius = 3
# Moves buildings - on first use some buildings get left behind? Test catapult in code below only appears after first use
newUnit = pPlayer.initUnit(iCata, iOnX, iOnY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
iXLow = iOffX - iRadius
iXHigh = iOffX + iRadius + 1
iXLimit = iOffX +iRadius
iYLow = iOffY - iRadius
iYHigh = iOffY + iRadius + 1
iYLimit = iOffY + iRadius
for iiX in range(iXLow, iXHigh, 1):
for iiY in range(iYLow, iYHigh, 1):
if not(iiX == iXLow and iiY == iYLow) and not (iiX == iXLow and iiY == iYLimit) and not (iiX == iXLimit and iiY == iYLow) and not (iiX == iXLimit and iiY == iYLimit):
pPlot = CyMap().plot(iiX,iiY)
iImp = pPlot.getImprovementType()
if iImp == iDormant:
pPlot.setImprovementType(iExp1)
The first time I trigger this event on a particular OffCity, the python seems to stop within the for movingbuilding loop. The second time its triggered, the loop completes as expected and the improvements are changed around OffCity.
Even if I remove all buildings from the OnCity before the event is triggered, the movingbuilding loop seems to fail on the first pass. Any ideas what would cause this failure and allow it to work the second time?
Will the onBuildingBuilt code in CvEventManager be triggered during this event if a wonder is built and if so will this interrupt the for movingbuilding loop? Will the onBuildingBuilt check only be performed after completion of all of the code in the event loop?
thanks,
LPlate
In the spoiler is some of the code from one of my python events.
Spoiler :
for movingBuilding in mobBuilding:
if pOnCity.getNumBuilding(movingBuilding)>0:
pOnCity.setNumRealBuilding((movingBuilding), 0)
pOffCity.setNumRealBuilding((movingBuilding), 1)
if movingBuilding == iSlums:
iRadius = 3
# Moves buildings - on first use some buildings get left behind? Test catapult in code below only appears after first use
newUnit = pPlayer.initUnit(iCata, iOnX, iOnY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
iXLow = iOffX - iRadius
iXHigh = iOffX + iRadius + 1
iXLimit = iOffX +iRadius
iYLow = iOffY - iRadius
iYHigh = iOffY + iRadius + 1
iYLimit = iOffY + iRadius
for iiX in range(iXLow, iXHigh, 1):
for iiY in range(iYLow, iYHigh, 1):
if not(iiX == iXLow and iiY == iYLow) and not (iiX == iXLow and iiY == iYLimit) and not (iiX == iXLimit and iiY == iYLow) and not (iiX == iXLimit and iiY == iYLimit):
pPlot = CyMap().plot(iiX,iiY)
iImp = pPlot.getImprovementType()
if iImp == iDormant:
pPlot.setImprovementType(iExp1)
The first time I trigger this event on a particular OffCity, the python seems to stop within the for movingbuilding loop. The second time its triggered, the loop completes as expected and the improvements are changed around OffCity.
Even if I remove all buildings from the OnCity before the event is triggered, the movingbuilding loop seems to fail on the first pass. Any ideas what would cause this failure and allow it to work the second time?
Will the onBuildingBuilt code in CvEventManager be triggered during this event if a wonder is built and if so will this interrupt the for movingbuilding loop? Will the onBuildingBuilt check only be performed after completion of all of the code in the event loop?
thanks,
LPlate