Caesium
Radiant!
- Joined
- Jan 14, 2006
- Messages
- 526
I tried to add a menu the Inquisiton Mod, in which you can choose, what religion should be removed from the city.
Can you tell me, where my mistake is?
Here are my files and the error message it puts on the screen:
CvCustomEventManager: (destilled to the main points)
Inqusitor.py
Can you tell me, where my mistake is?
Here are my files and the error message it puts on the screen:
CvCustomEventManager: (destilled to the main points)
PHP:
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
##
## This class is passed an argsList from CvAppInterface.onEvent
## The argsList can contain anything from mouse location to key info
## The EVENTLIST that are being notified can be found
######################################################################################################
# import
######################################################################################################
from CvPythonExtensions import *
import CvUtil
import CvScreensInterface
import CvDebugTools
import CvWBPopups
import PyHelpers
import Popup as PyPopup
import CvCameraControls
import CvTopCivs
import CvEventManager
import sys
import Inquisition
######################################################################################################
# renaming
######################################################################################################
gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo
inq = Inquisition.Inquisition()
######################################################################################################
# Custom Eventmanager
######################################################################################################
class CvCustomEventManager(CvEventManager.CvEventManager):
def __init__(self):
# initialize base class
self.parent = CvEventManager.CvEventManager
self.parent.__init__(self)
self.Events[7504] = ('', self.__eventInquisitionApply , self.__eventInquisitionBegin)
self.__LOG_TECH = 0
def onBuildingBuilt(self, argsList):
self.parent.onBuildingBuilt(self, argsList)
inq.onBuildingBuilt(argsList)
def __eventInquisitionBegin(self, argsList): #7504
inq.eventInquisitionBegin(argsList)
def __eventInquisitionApply(self, playerID, userData, popupReturn):
inq.eventInquisitionApply(playerID, userData, popupReturn)
Inqusitor.py
PHP:
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
from CvPythonExtensions import *
import CvUtil
import Popup as PyPopup
import CvCustomEventManager
# globals
gc = CyGlobalContext()
localText = CyTranslator()
class Inquisition:
def __init__(self):
self.list = []
def onBuildingBuilt(self, argsList):
pCity, iBuildingType = argsList
iInquisition = gc.getInfoTypeForString('BUILDING_INQUISITION')
if iBuildingType == iInquisition:
self.list = []
iPlot = pCity.plot()
iPlayer = iPlot.calculateCulturalOwner()
StateBelief = gc.getPlayer(pCity.getOwner()).getStateReligion()
for i in range(gc.getNumReligionInfos()):
if not StateBelief == i:
if pCity.isHasReligion(i):
if not pCity.isHolyCityByType(i):
self.list.append(i)
if((len(self.list) > 0) and (gc.getPlayer(iPlayer).isHuman() == 1)):
CvCustomEventManager.CvCustomEventManager().beginEvent(7504)
elif((len(self.list) > 0) and (gc.getPlayer(iPlayer).isHuman() == 0)):
iTarget = self.list[CyRandom().get(len(self.list), "Get a random number for religion removal.")]
pCity.setHasReligion(iTarget, False, True, True)
for i in range(gc.getNumBuildingInfos()):
if gc.getBuildingInfo(i).getPrereqReligion() == iTarget:
pCity.setHasRealBuilding(i, False)
self.list = []
pCity.setHasRealBuilding(iInquisition, False)
def eventInquisitionBegin(self, argsList):
message='The Inquisition strikes again!'
popup = PyPopup.PyPopup(7504, EventContextTypes.EVENTCONTEXT_ALL)
popup.setHeaderString(localText.getText("TXT_KEY_INQUISITION_CHOICE", ()))
popup.createPullDown()
for i in range(0 , len(self.list)):
popup.addPullDownString(gc.getReligionInfo(self.list[i]).getDescription() , i)
popup.addButton("OK")
popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
CyInterface().addMessage(CyGame().getActivePlayer(),True,25,message,'AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/Actions/Pillage.dds',ColorTypes(7),pCity.getX(),pCity.getY(),True,True)
return
def eventInquisitionApply(self, argsList, userData, popupReturn):
pCity, iBuildingType = argsList
if (popupReturn.getButtonClicked() == 0):
iTarget = self.list[popupReturn.getSelectedPullDownValue(0)]
pCity.setHasReligion(iTarget, False, True, True)
self.list = []
return
Traceback (most recent call last):
File "CvEventInterface", line 23, in onEvent
File "CvEventManager", line 164, in handleEvent
File "CvCustomEventManager", line 104, in onBuildingBuilt
File "Inquisition", line 32, in onBuildingBuilt
File "CvEventManager", line 171, in beginEvent
File "CvCustomEventManager", line 263, in __eventInquisitionBegin
File "Inquisition", line 52, in eventInquisitionBegin
NameError: global name 'pCity' is not defined
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):
File "CvEventInterface", line 27, in applyEvent
File "CvEventManager", line 184, in applyEvent
File "CvCustomEventManager", line 266, in __eventInquisitionApply
File "Inquisition", line 56, in eventInquisitionApply
TypeError: unpack non-sequence
ERR: Python function applyEvent failed, module CvEventInterface