Hi! I am new to Python scripting, and already create successful python scripts (well can hardly call a script; it was three popups which was scripted to iGameTurn == 1, 3, and 5 and called at onBeginGameTurn) so I wanted to script that if the popup comes, the turkish will declare war on the russian.
Here is the base code of the popup:
So I took a look at the python API, but I don't know how to use what I found
I found isDeclareWar () but I don't how can I use it. I tried getCivilizationTypes and use the ID in my XML. Tried the following noob code:
getCivilizationTypes (7) = gc.DeclareWar CivilizationTypes (3)
So the new code looks like this:
So I started the game and after the scripted time, Python Exception gave the following error message:
Please be kind. I never did such thing before. I still need to learn about Python.
Here is the base code of the popup:
Code:
def onBeginGameTurn(self, argsList):
'Called at the beginning of the end of each turn'
iGameTurn = argsList[0]
CvTopCivs.CvTopCivs().turnChecker(iGameTurn)
if iGameTurn == 3:
for iPlayer in range(gc.getMAX_PLAYERS()):
player = gc.getPlayer(iPlayer)
if (player.isAlive() and player.isHuman()):
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
popupInfo.setText("THE RUSSO-TURKISH WAR\n\nIn 1806, Sultan Selim III, encouraged by the Russian defeat at Austerlitz and adviced by the French Empire, deposed the pro-Russian Constantine Ypsilanti as Hospodar of the Principality of Wallachia and Alexander Mourousis as Hospodar of Moldavia, both Ottoman vassal states. Simultaneously, the French Empire occupied Dalmatia and threatened to penetrate the Danubian principalities at any time. In order to safeguard the Russian border against a possible French attack, a 40,000-strong Russian contingent advanced into Moldavia and Wallachia. The Sultan reacted by blocking the Dardanelles to Russian ships and declared war on Russia.")
popupInfo.addPopup(iPlayer)
So I took a look at the python API, but I don't know how to use what I found

I found isDeclareWar () but I don't how can I use it. I tried getCivilizationTypes and use the ID in my XML. Tried the following noob code:
getCivilizationTypes (7) = gc.DeclareWar CivilizationTypes (3)
So the new code looks like this:
Code:
def onBeginGameTurn(self, argsList):
'Called at the beginning of the end of each turn'
iGameTurn = argsList[0]
CvTopCivs.CvTopCivs().turnChecker(iGameTurn)
if iGameTurn == 3:
for iPlayer in range(gc.getMAX_PLAYERS()):
player = gc.getPlayer(iPlayer)
[COLOR="Red"]isDeclareWar = gc.getCivilizationTypes (7 , 3)[/COLOR]
if (player.isAlive() and player.isHuman()):
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
popupInfo.setText("THE RUSSO-TURKISH WAR\n\nIn 1806, Sultan Selim III, encouraged by the Russian defeat at Austerlitz and adviced by the French Empire, deposed the pro-Russian Constantine Ypsilanti as Hospodar of the Principality of Wallachia and Alexander Mourousis as Hospodar of Moldavia, both Ottoman vassal states. Simultaneously, the French Empire occupied Dalmatia and threatened to penetrate the Danubian principalities at any time. In order to safeguard the Russian border against a possible French attack, a 40,000-strong Russian contingent advanced into Moldavia and Wallachia. The Sultan reacted by blocking the Dardanelles to Russian ships and declared war on Russia.")
popupInfo.addPopup(iPlayer)
So I started the game and after the scripted time, Python Exception gave the following error message:
I assume I did something terrible in that code.'CyGlobalContent' object has no attribute 'getCivilizationTypes'

Please be kind. I never did such thing before. I still need to learn about Python.
