Python help

cromcrom

Cernu
Joined
Nov 11, 2005
Messages
268
Location
Chateauroux
PLease,
I started learning python, and could do some very basic programming. But I can't figure how CIV4 works :confused: . Could anybody be kind enough to explain me how to make a window popup every turns, for example, saying, "hello world! "... You know, the very basic stuff :( .

Please help, I am getting crazy having something that simple work...
:crazyeye:
 
To have a popup every turn, open your CvEventManager.py. It stores many events that happen during the game (when a city is built, when a player begins a turn, when an improvement is built, and so on).
So just look at the event called onBeginPlayerTurn. It is called each time a player begins a turn.
It looks like this:
Code:
	def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		iGameTurn, iPlayer = argsList

To have a popup every turn, just do that:
Code:
	def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		iGameTurn, iPlayer = argsList
                if (gc.getPlayer(iPlayer).isHuman()):
				popup = PyPopup.PyPopup()
                                popup.setBodyString('Hello World')
                                popup.launch()
And that's it !
I think that the better way for you to learn how python works with Civ4 is to check existing mod and look at their code. And there is some tutorials that you also may check ;)
 
Thanks a lot major :)
I have been trying to figure out the mods, what goes where, but got lost beetween all the self.parent.son.aunt.grandma() there are around, it drives me crazy. I am gonna try your stuff anyway, thanks again :)
 
Back
Top Bottom