Shqype
Shqyptar
Now that I've gotten into it, I'm making slight progress. For one, no python errors upon loading the mod. Secondly, more parts of the code are working. I took out the SD-Toolkit related parts and decided to just do it the 'old fashioned way' as you have shown me how to do, Belizan. For some reason I had a mental block earlier and couldn't understand, but now coming back to it I see that it was pretty simple, especially since you gave me your own code:
My onImprovementBuilt looks something like this:
This game me an error:
Now, what other argument was I giving in the first example? And, after changing it, why the new error about setScriptData? How are these issues resolved?
In order to stop 1 check for each player, I changed the code to "onBeginGameTurn" instead of "onBeginPlayerTurn." It works nicely. I set up popups after my if statements to make sure I at least made it that far. The map scan for the improvement does in fact return a value that it found the improvement, and the appropriate popup comes up every turn after the improvement was built, so I'm happy about that.
Code:
def initPlotDictionary(pPlot):
plotDict = {}
pPlot.setScriptData(cPickle.dumps(plotDict))
def getPlotDictionary(pPlot):
plotDict = cPickle.loads(pPlot.getScriptData())
return plotDict
def setPlotDictionary(pPlot, plotDict):
pPlot.setScriptData(cPickle.dumps(plotDict))
def getTurnImpBuilt(pPlot):
plotDict = getPlotDictionary(pPlot)
return plotDict["turnImpBuilt"]
def getOriginalOwner(pPlot):
plotDict = getPlotDictionary(pPlot)
return plotDict["originalOwner"]
My onImprovementBuilt looks something like this:
Code:
def onImprovementBuilt(self, argsList):
'Improvement Built'
self.parent.onImprovementBuilt(self, argsList)
iImprovement, iX, iY = argsList
pPlot = gc.getMap().plot(iX, iY)
pPlayer = gc.getPlayer(pPlot.getOwner())
if (iImprovement == gc.getInfoTypeForString('IMPROVEMENT_ANIMAL_DEN')):
newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_AXEMAN'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI)
self.initPlotDictionary(pPlot)
self.setPlotDictionary(pPlot, plotDict)
So I changed to this instead:initPlotDictionary() takes exactly 1 argument (2 given)
Code:
self.initPlotDictionary()

Now, what other argument was I giving in the first example? And, after changing it, why the new error about setScriptData? How are these issues resolved?
In order to stop 1 check for each player, I changed the code to "onBeginGameTurn" instead of "onBeginPlayerTurn." It works nicely. I set up popups after my if statements to make sure I at least made it that far. The map scan for the improvement does in fact return a value that it found the improvement, and the appropriate popup comes up every turn after the improvement was built, so I'm happy about that.