TGA's Python Tutorial

Thanks for this great tutorial, found it when you responded to another message of mine.

Looking at the .ini file, there is an entry

; Establish connection to Python Debugger
HAPDebugger = 0

Any idea what this does?
 
I have used it. You need to download HAP Debugger, then set HAPDebugger=1, now start civ4, it will be paused when loading Python, then start HAP Debugger, and load file CvAppInterface.py, then you can debug in HAP Debugger.
 
pholtz said:
Thanks for this great tutorial, found it when you responded to another message of mine.
Ditto, and my sentiments exactly!
 
Hey TGA.

My Python mods do not seem to do anything. What am i doing wrong? I tried displaying your message (the new turn 1, about "You have just started a new turn" or whatever it was). I put it into MyMod/Assets/Python/CvEventManager.py in exactly the same place you did and it had no effect whatsoever (im thinking it should display in the top left hand corner, would i be right there?).

Its not the first time iv tried to do something of the sort- i tried putting a welcome back message when the game loaded and that didnt do anything either.

Is there any reason you can think of why it aint working?

thanks,
mrkingkong
 
Just found out if you do , do the debugging it slows down the "waiting for next civ" ALOT. Mine is a 3Gz, 2G memory and a 250 HD, and lag time with debugger is from 25 seconds to two minutes for each turn (and thats for only three civs). Put the normal ini file back in and the lag time changes to under 8 seconds each turn.
So in other words, if your not testing and just want to play , go back to the original ini file ALOT faster.
 
Thks. Excellent overview. The examples really help get me started modding things.
 
Hi,
I want to address a single field in range of an unit in Python. Something like, if <the tile/filed is a grassland> ...
How do I do this in Python? Address an special field in range of a unit and ask about the properties of that field?
Kind regards an thank you very very much für a response,
Bothrochilus
 
PHP:
iX = pUnit.getX()
iY = pUnit.getY()
map=CyMap()

for iXLoop in range(iX - 1, iX + 2, 1):
	for iYLoop in range(iY - 1, iY + 2, 1):
                thisplot=map.plot(iXLoop,iYLoop)
                terrain = thisplot.getTerrainType ()
                feature = thisplot.getFeatureType ()

This will need a CyUnit instance, and check every plot around it for the terrain type and the feature.

What do you want to do?
 
A great tutorial!
But I have a question: As I enter a code like this
Code:
if attacker.hasTrait(1): #Trait Agressive
	attacker.changeGold(2)
(attacker is a PyPlayer instance)
in CvEventManager.py, I get an Error, when the event occcurs:
"an instance of PyPlayer has no Attribute "hasTrait".
I test a lot of other functions, the most with parameters doesn´t work.
 
Top Bottom