ww2commander
Emperor
I have just got into learning python and have made some progress, but I seem to have run into a problem which I know is simple to solve but cant figure it out.
Below is some code that changes the season terrain of my map. The season code work fine but I cant seem to get the game to recognize the boolean value bReDraw (which I have bolded)!
The way the code works is as follows:
1. A popup passes a value to SelectRedrawMethod.
2. SelectRedrawMethod then passes the respective true/false flag to ChangeSeasons which should use it in the setTerrainType function when using the part.
The game does not recognise the value and ignores it. I checked the python logs and it says nothing! Can anyone suggest why setTerrainType does not recognise my boolean value. It works fine when I actually type in the value rather than use the boolean flag.

Below is some code that changes the season terrain of my map. The season code work fine but I cant seem to get the game to recognize the boolean value bReDraw (which I have bolded)!
The way the code works is as follows:
1. A popup passes a value to SelectRedrawMethod.
2. SelectRedrawMethod then passes the respective true/false flag to ChangeSeasons which should use it in the setTerrainType function when using the part.
The game does not recognise the value and ignores it. I checked the python logs and it says nothing! Can anyone suggest why setTerrainType does not recognise my boolean value. It works fine when I actually type in the value rather than use the boolean flag.
Code:
def SelectRedrawMethod(argList):
iButtonId = argsList[0]
iData1 = argsList[1]
iData2 = argsList[2]
iData3 = argsList[3]
iData4 = argsList[4]
szText = argsList[5]
bOption1 = argsList[6]
bOption2 = argsList[7]
pPlayer = gc.getPlayer(iData)
iMethod = -1
if iButtonId == 0:
self.ChangeSeason(0)
if iButtonId == 1:
self.ChangeSeason(1)
def ChangeSeason(self, value):
[B]bReDraw = False[/B]
if value == 0:
[B]bRedraw = True[/B]
elif value == 1:
[B]bReDraw = False[/B]
bFreeze = False
if iTurn % 2 == 0:
szMessage = "Winter Freeze"
bFreeze = True
else:
szMessage = "Spring Thaw"
bFreeze = False
map = CyMap()
for y in range(map.getGridHeight()):
for x in range(map.getGridWidth()):
plot = CyMap().plot(x,y)
#iTerrainType = plot.getTerrainType()
if bFreeze: #Make terrain into winter
if plot.getTerrainType() == 0:
plot.setTerrainType(12, True, [B]bRedraw[/B])
elif plot.getTerrainType() == 1:
plot.setTerrainType(13, True, [B]bRedraw[/B])
elif plot.getTerrainType() == 3:
plot.setTerrainType(14, True, [B]bRedraw[/B])
elif plot.getTerrainType() == 5:
plot.setTerrainType(15, True, [B]bRedraw[/B])
elif plot.getTerrainType() == 6:
plot.setTerrainType(16, True, [B]bRedraw[/B])
if plot.getFeatureType() == 5 and plot.getFeatureVariety() == 0: #Leafy forest
plot.setFeatureType(5, 4)
elif plot.getFeatureType() == 5 and plot.getFeatureVariety() == 1: #Evergreen forest
plot.setFeatureType(5, 3)
else: # Make terrain into summer
if plot.getTerrainType() == 12:
plot.setTerrainType(0, True, [B]bRedraw[/B])
elif plot.getTerrainType() == 13:
plot.setTerrainType(1, True, [B]bRedraw[/B])
elif plot.getTerrainType() == 14:
plot.setTerrainType(3, True, [B]bRedraw[/B])
elif plot.getTerrainType() == 15:
plot.setTerrainType(5, True, [B]bRedraw[/B])
elif plot.getTerrainType() == 16:
plot.setTerrainType(6, True, [B]bRedraw[/B])
if plot.getFeatureType() == 5 and plot.getFeatureVariety() == 4: #Snowy Leafy forest
plot.setFeatureType(5, 0)
elif plot.getFeatureType() == 5 and plot.getFeatureVariety() == 3: #Snowy Evergreen forest
plot.setFeatureType(5, 1)
return 1