DasGuntLord01
Chieftain
- Joined
- Feb 11, 2010
- Messages
- 80
I'm trying to make a simple mod that will let one player watch a duel between two others: a spectator mod!
One of the things that is annoying for both spectator and player is that the spectator still needs to end turn manually. Since the "wait until end of turn" option doesn't actually work properly, I thought a solution might lie in python: at the beginning of the spectators turn, can I force the turn to end immediately?
The "Defense" mod that comes with BTS uses CyMessageControl().sendTurnComplete(), which works like a charm in that mod. But it doesn't work for me in mine. Here is my code.
CvEventManager.py
my forceTurn.py:
This throws no errors, but does NOT end the players turn.
Does anyone have any advice? Thanks in advance.
EDIT: As part of the mod, I have added in extra civ ("Spectator 1") that IS civ 36, and the use of the popup in the above code verifies this.
With God-Emperors suggestion (below) I removed the popup code, and this did not solve the problem.
One of the things that is annoying for both spectator and player is that the spectator still needs to end turn manually. Since the "wait until end of turn" option doesn't actually work properly, I thought a solution might lie in python: at the beginning of the spectators turn, can I force the turn to end immediately?
The "Defense" mod that comes with BTS uses CyMessageControl().sendTurnComplete(), which works like a charm in that mod. But it doesn't work for me in mine. Here is my code.
CvEventManager.py
Code:
def onBeginPlayerTurn(self, argsList):
'Called at the beginning of a players turn'
iGameTurn, iPlayer = argsList
forceTurn.checkForceTurn(iPlayer)
my forceTurn.py:
Code:
from CvPythonExtensions import *
from PyHelpers import *
from Popup import PyPopup
import time
gc = CyGlobalContext()
cyGame = CyGame()
cyMap = CyMap()
pyGame = PyGame()
eng = CyEngine()
def checkForceTurn(player):
cyPlayer = gc.getPlayer(player);
iCivType = cyPlayer.getCivilizationType();
if iCivType >= 36: ##civs 36+ are spectator civs
modPopup = PyPopup()
modPopup.setHeaderString("New Turn")
modPopup.setBodyString("Attempting to force end of turn. %i" % (iCivType))
modPopup.launch()
CyMessageControl().sendTurnComplete()
This throws no errors, but does NOT end the players turn.
Does anyone have any advice? Thanks in advance.
EDIT: As part of the mod, I have added in extra civ ("Spectator 1") that IS civ 36, and the use of the popup in the above code verifies this.
With God-Emperors suggestion (below) I removed the popup code, and this did not solve the problem.