Can't Create Popup

deanej

Deity
Joined
Apr 8, 2006
Messages
4,859
Location
New York State
I keep trying to make a popup, yet each and every game I test it out in it acts as if I never made any changes at all! Here's the code, located at the end of onEndGameTurn (this code is currently the only python change):
Code:
                #Ice Age Mod Start
		if (iGameTurn == 2):
                    for iPlayer in range(gc.getMAX_PLAYERS()):
                        player = gc.getPlayer(iPlayer)
                        if (player.isAlive() and player.isHuman()):
                            popupInfo = CyPopupInfo()
                            popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
                            szBody = localText("TXT_KEY_ICE_AGE", ())
                            popupInfo.setText(szBody)
                            popupInfo.addPopup(iPlayer)
                #Ice Age Mod End

I'm getting very frustrated. The form is identical to that used to create the pirates tutorial text in the Final Frontier scenario except that mine doesn't check to see if an option is on, yet mine doesn't work. Why does the game discriminate against me? It's the same code!
 
Well, I am certainly no Python genius, though I've had my fair share of experience, but here it goes...

First, and the most obvious question... is the indentation correct? (Sounds stupid, I know, but sometimes it can fool you. If it's a stock function, then it's probably okay.) Second, I'm not sure if onEndGameTurn is exactly the function you want for this, but then I don't know what you're ultimately trying to do beyond making a popup. For a turn-triggered event I usually use checkPlayerTurnEvents, not onEndGameTurn, so I don't know if that would be a problem or not.

If it's the exact same code that worked elsewhere, and it does not use any special functions or variables (which it doesn't appear to) then it could just be that you've put it in the wrong place. Does onEndGameTurn get both the player and the turn passed to it?
 
You have 7 players, I take it? Hmm... if you have the isHuman check it should not display seven times (unless you've set seven human players, of course). Do you have it embedded in some other loop that might be causing it?
 
Back
Top Bottom