Eusebius
Warlord
Hephaistion said:Thanks for your help -- after a few days of tinkering, and eliminating arrangements that give me tons of errors all over the place, I've come down to one consistent error:
Traceback:
File "CivAppInterface", line 47, onSave
Attribute Error: 'module' object has no attribute 'onEvent'
Here's my CvCustomEventManager setup (the part I've been messing with):
Spoiler :import CvEventManager
import CvConfigParser
import CvEnhancedTechConquestEventManager
import CvEnhancedCulturalDecayEventManager
# --------- Revolution mod -------------
import RevUtils
import BarbarianCiv
import AIAutoPlay
import ChangePlayer
import Revolution
import Tester
# ---------- World Religions Mod ----------
import SettlerReligion
import TPEventManager
import ewr
import euMap
gc = CyGlobalContext()
m_moduleList = {}
def getModule(sName):
return m_moduleList.get(sName, -1)
class CvCustomEventManager(CvEventManager.CvEventManager, object):
def __init__(self, *args, **kwargs):
super(CvCustomEventManager, self).__init__(*args, **kwargs)
# map the initial EventHandlerMap values into the new data structure
for eventType, eventHandler in self.EventHandlerMap.iteritems():
self.setEventHandler(eventType, eventHandler)
# --> INSERT EVENT HANDLER INITIALIZATION HERE <--
CvEnhancedTechConquestEventManager.CvEnhancedTechConquestEventManager(self)
CvEnhancedCulturalDecayEventManager.CvEnhancedCulturalDecayEventManager(self)
config = CvConfigParser.CvConfigParser("HephMod.ini")
if( config.getboolean("AIAutoPlay", "Enable", True) ) :
AIAutoPlay.AIAutoPlay(self, config)
if( config.getboolean("BarbarianCiv", "Enable", True) ) :
BarbarianCiv.BarbarianCiv(self, config)
if( config.getboolean("ChangePlayer", "Enable", False) ) :
ChangePlayer.ChangePlayer(self, config)
if( config.getboolean("Revolution", "Enable", False) ) :
Revolution.Revolution(self, config)
RevUtils.registerEvents( self, config )
m_moduleList['ewr'] = ewr.ewr(self)
m_moduleList['euMap'] = euMap.euMap(self)
m_moduleList['SettlerReligion'] = SettlerReligion.SettlerReligion(self)
m_moduleList['TpEventManager'] = TPEventManager.TPEventManager(self)
# This component now handles all the mod issue reporting (ActivePopup, etc)
Tester.Tester( self, config )
def beginEvent( self, context, argsList=-1 ):
"Begin Event"
if(self.CustomEvents.has_key(context)):
return self.CustomEvents[context][2](argsList)
else:
return CvEventManager.CvEventManager.beginEvent(self, context, argsList)
def applyEvent( self, argsList ):
'Apply the effects of an event '
context, playerID, netUserData, popupReturn = argsList
if(self.CustomEvents.has_key(context)):
entry = self.CustomEvents[context]
# the apply function
return entry[1]( playerID, netUserData, popupReturn )
else:
return CvEventManager.CvEventManager.applyEvent(self, argsList)
def addCustomEventDefinition(self, eventType, eventDefinition):
self.CustomEvents[eventType] = eventDefinition
def removeCustomEventDefinition(self, eventType):
del self.CustomEvents[eventType]
def setCustomEventDefinition(self, eventType, eventDefinition):
self.CustomEvents[eventType] = eventDefinition
I copied and pasted all those additional "def" entries starting with def Begin Event from the EWR CvCustomEventManager ... wasn't sure if I needed them or not ...
Any thoughts?
You know, I've seen this sort of error once in a blue moon, inconsistantly.
There is nothing I can see wrong in your code. This type of error wants me want to make sure I have an absolutely clean environment--reboot, start a new game, etc. I don't know about you, but I tend to test Python by finding an error, alt-tabbing to editor and changing the python, alt-tabbing back, etc. Once in a while things get hosed that way. Sorry not to be more help. This is precisely the sort of Python question I am weakest on.
The extra defs came with jzoc which is where I got my CvCustomEventManager. I wasn't aware they were non-standard.
Eusebius