python question

srpt

Deist
Joined
May 10, 2010
Messages
2,038
Location
Toronto
I am trying to add 4 more unit spawns to the roman spawn, 1 each in greece, anatolia, egypt/levant and north africa.

here is my attempt, added to createstartingunits in RiseAndFall:

Code:
if (iCiv == iRome):
                        utils.makeUnit(con.iSettler, iCiv, tPlot, 3)
                        utils.makeUnit(con.iArcher, iCiv, tPlot, 3)
                        utils.makeUnit(con.iRomePraetorian, iCiv, tPlot, 1) 
                        tSeaPlot = self.findSeaPlots(tPlot, 1, iCiv)
                        if (tSeaPlot):                                
                                utils.makeUnit(con.iWorkBoat, iCiv, tSeaPlot, 1)
                                pRome.initUnit(con.iGalley, tSeaPlot[0], tSeaPlot[1], UnitAITypes.UNITAI_ASSAULT_SEA, DirectionTypes.DIRECTION_SOUTH)
                                pRome.initUnit(con.iGalley, tSeaPlot[0], tSeaPlot[1], UnitAITypes.UNITAI_ASSAULT_SEA, DirectionTypes.DIRECTION_SOUTH)
                        tLegionPlot1 = utils.squareSearch( (54, 39), (58, 39), utils.outerInvasion, [])#north africa
                        if (tLegionPlot1):
                                utils.makeUnit(con.iRomePraetorian, iCiv, tLegionPlot1, 3)
                        tLegionPlot2 = utils.squareSearch( (65, 36), (73, 38), utils.outerInvasion, [])#egypt
                        if (tLegionPlot2):
                                utils.makeUnit(con.iRomePraetorian, iCiv, tLegionPlot2, 3)
                        tLegionPlot3 = utils.squareSearch( (63, 43), (68, 45), utils.outerInvasion, [])#greece
                        if (tLegionPlot3):
                                utils.makeUnit(con.iRomePraetorian, iCiv, tLegionPlot3, 3)
                        tLegionPlot4 = utils.squareSearch( (69, 40), (72, 44), utils.outerInvasion, [])#anatolia
                        if (tLegionPlot4):
                                utils.makeUnit(con.iRomePraetorian, iCiv, tLegionPlot4, 3)

and here is what I got:



Can someone point me in the right direction?
 
I don't have the program here, so I can't be sure, but it looks like your way of finding the tLegionPlots is causing this.
 
You pass the wrong arguments it seems. Look into the method's signature: it seems you're passing a None pointer and a list into what expects an integer each. Don't know where the list comes from, but the none seems to be your tLegionTuple which may not have been found (by the squareSearch method). Have the code print repr(tLegion) and look into the logs whether it actually contains a tuple of coordinates.
 
Can you be more specific on how to find the fault? I added the print command to the code after the plot search and got the same result. I can't find the logs you refer to. I looked here: C:\Documents and Settings\user\My Documents\My Games\Beyond the Sword\Logs (same parent folder as my save games and screenshots) but though there were text files there none seemed to relate. When I use the print command in the python console I get this:

Spoiler :


Thanks, and thanks to both of you for all your modding efforts, which I've really enjoyed.

or of course if you think I am not going about this in the best way, please let me know.
 
No, I meant add the print command right after the part in your module where you search for the tLegionPlot. You'll then find the printed lines in the PythonDbg file in the folder you've already found :)
 
I added the print command to RiseAndFall, right after the tLegionPlot search, like this:

Code:
if (iCiv == iRome):
                        utils.makeUnit(con.iSettler, iCiv, tPlot, 3)
                        utils.makeUnit(con.iArcher, iCiv, tPlot, 3)
                        utils.makeUnit(con.iRomePraetorian, iCiv, tPlot, 1) #Jarkov
                        tSeaPlot = self.findSeaPlots(tPlot, 1, iCiv)
                        if (tSeaPlot):                                
                                utils.makeUnit(con.iWorkBoat, iCiv, tSeaPlot, 1)
                                pRome.initUnit(con.iGalley, tSeaPlot[0], tSeaPlot[1], UnitAITypes.UNITAI_ASSAULT_SEA, DirectionTypes.DIRECTION_SOUTH)
                                pRome.initUnit(con.iGalley, tSeaPlot[0], tSeaPlot[1], UnitAITypes.UNITAI_ASSAULT_SEA, DirectionTypes.DIRECTION_SOUTH)
                        tLegionPlot1 = utils.squareSearch( (54, 39), (58, 40), utils.outerInvasion, [])#north africa
                        print repr(tLegionPlot1)

which doesn't seem to generate a PythonDbg file in that folder.
 
Oh, sorry, you might have to enable Python logging in your Civ4 settings file first.
 
Back
Top Bottom