Why this is not working?

Quitos

Chieftain
Joined
Jan 2, 2006
Messages
37
as i am trying to learn modding,, i tried to add to Holistic Culture Mod

to:
CvCustomEventManager


i added this :

cMap = CyMap()
cG = cyGame()

and this event:

def onRouteBuilt(self, argsList):
iRoute = argsList[0]
iX = argsList[1]
iY = argsList[2]
pPlayer = cG.getActivePlayer()
pPlot = cMap.getPlot(iX,iY)
plotOwner = pPlot.getOwner()
if plotOwner == -1:
pPlot.setOwner(pPlayer)

===
i am trying to let player OWN the unowned tile by building a road on it !!!

nothing happen



Q2: how can i debug python on CIV 4
 
Become one with the attached CivilizationIV.ini file. It has the debug options turned on. It goes in your '..\My Documents\My Games\Sid Meier's Civilization 4' directory. It should give you some clue as to what is going wrong.

And I would guess that it isn't working because getActivePlayer returns an index, not a PyPlayer object.
 
Please use [ tab ] (without spaces) when posting code here so the indention shows. Both makes it easier to read and easier to find out if that is what causes the problem.

Kael said:
And I would guess that it isn't working because getActivePlayer returns an index, not a PyPlayer object.
But CyPlot.setOwner takes an int as parameter, the same thing that getActivePlayer returns.

Quitos said:
cG = cyGame()
Pretty sure that should be CyGame().
 
snarko said:
Please use [ tab ] (without spaces) when posting code here so the indention shows. Both makes it easier to read and easier to find out if that is what causes the problem.


But CyPlot.setOwner takes an int as parameter, the same thing that getActivePlayer returns.


Pretty sure that should be CyGame().

Ahh, good point.
 
One more thing. If you don't have any culture on a plot you can be set as the owner but when the game recalculates who owns which plot you will lose ownership. Giving the player one culture point on the plot might be enough to prevent this from happening.
 
Hmm, so another thread was asking about Civ3 colonies - could we just give a civilization one culture point on the plot, and have everything work? Must test, must test...
 
thanks all.
i used CyGame.getActivePlayer() because it returns an index. while CyGlobalContext.getActivePlayer() returns a player object!!
i'll try the ideas mentioned.. hope it will work.

thnaks all
 
Quitos said:
thanks all.
i used CyGame.getActivePlayer() because it returns an index. while CyGlobalContext.getActivePlayer() returns a player object!!
i'll try the ideas mentioned.. hope it will work.

thnaks all

Right you are. For my own sanity (or for what little is left) I usually name my variables according to the data type. So any interger starts with an i (iPlayer, iUnit, iDmg, etc), any Boolean starts with a b (bImmune, bAnimal, etc) and any objects start with a p (pPlayer, pPlot, pUnit).
 
Hungarian notation for Python uses 'p' for objects because the internal representation of objects is a pointer. Makes sense to people who know C or Assembly, is just a convention to learn for anybody weaned on newer languages that are farther from the memory model.
 
Lord Olleus said:
why 'p' for objects?
i know thats what the game uses but it makes little sence to me

Yeah, Im just following the games naming standards for consistency. If it was up to me I would use an o for object or c for Class object. But I figure if we follow Firaxis's lead in naming standards it will make it easier to read each others code.
 
i first used the object just to discover that i had to put an index.. and was lazy to change variable names
 
still no working properly (as i wanted).. now it just makes the new city expands boarder immediately!!!
 
Back
Top Bottom