1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

StoredData.py

Discussion in 'Rhye's and Fall Modmods' started by Linkman226, Aug 29, 2011.

  1. Linkman226

    Linkman226 #anarchy

    Joined:
    Sep 14, 2007
    Messages:
    2,493
    Alright I added a minor civ to my mod and it's throwing a python exception:

    Spoiler :
    Code:
    Traceback (most recent call last):
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "<string>", line 1, in ?
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "<string>", line 52, in load_module
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "CvEventInterface", line 13, in ?
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "<string>", line 52, in load_module
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "CvRFCEventManager", line 5, in ?
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "<string>", line 52, in load_module
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "CvEventManager", line 12, in ?
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "<string>", line 52, in load_module
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "CvScreensInterface", line 3, in ?
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "<string>", line 52, in load_module
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "CvMainInterface", line 17, in ?
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "<string>", line 52, in load_module
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "CvMercenaryManager", line 25, in ?
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "MercenaryUtils", line 270, in __init__
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "SdToolKit", line 137, in sdEntityExists
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "SdToolKit", line 96, in sdModLoad
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
      File "SdToolKit", line 76, in sdModInit
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    AttributeError
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    : 
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    'NoneType' object has no attribute 'setScriptData'
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    Failed to load python module CvEventInterface.
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    


    I know it has to do with StoredData.py(or I think it does... at least it appears to, correct me if I'm wrong). But I made sure to add an array element to every array where it was nescesary, specifically:

    lNumCities
    lLastTurnAlive
    lRomanWars
    lMemory
    lPlagueCountdown
    lFirstContactPlague

    And yet it stills throws the error above. What gives?

    In advance, thank you for all your help.

    Full text of my StoredData.py file:

    Spoiler :
    Code:
    # Rhye's and Fall of Civilization - Stored Data
    
    from CvPythonExtensions import *
    import CvUtil
    import PyHelpers  
    import cPickle as pickle
    
    # globals
    gc = CyGlobalContext()
    PyPlayer = PyHelpers.PyPlayer	
    
    
    class StoredData:
    
            def __init__(self):
                    self.setup()
    
            def load(self):
                    """Loads and unpickles script data"""
                    self.scriptDict = pickle.loads(gc.getGame().getScriptData())
    
            def save(self):
                    """Pickles and saves script data"""
                    gc.getGame().setScriptData(pickle.dumps(self.scriptDict))
    
            def setup(self):
                    """Initialise the global script data dictionary for usage."""
                    self.scriptDict = {      #------------RiseAndFall
                                        'iNewCiv': -1,
                                        'iNewCivFlip': -1,
                                        'iOldCivFlip': -1,
                                        'tTempTopLeft': -1,
                                        'tTempBottomRight': -1,
                                        'iSpawnWar': 0, #if 1, add units and declare war. If >=2, do nothing
                                        'bAlreadySwitched': False,
                                        'lColonistsAlreadyGiven': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #active players
                                        'lAstronomyTurn': [1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500], #active players
                                        'lNumCities': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #total players to contain Byzantium too
                                        'lLastTurnAlive': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #total players to contain Byzantium too
                                        'lSpawnDelay': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #active players
                                        'lFlipsDelay': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'iBetrayalTurns': 0,
                                        'lLatestRebellionTurn': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'iRebelCiv': 0,
                                        'lExileData': [-1, -1, -1, -1, -1],
                                        'tTempFlippingCity': -1,
                                        'lCheatersCheck': [0, -1],
                                        'lBirthTurnModifier': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lDeleteMode': [-1, -1, -1], #first is a bool, the other values are capital coordinates
                                        'lFirstContactConquerors': [0, 0, 0], #maya, inca, aztecs
                                        'bCheatMode': False,
    				    'tTempFlippingCity': (0, 0),
                                         #------------Religions
                                        'iSeed': -1,
                                        'bOrthodoxyFounded': False,
                                        'iOrthodoxyFoundDate': 0,
                                        #------------UP
                                        'iImmigrationTurnLength': 0,
                                        'iImmigrationCurrentTurn': 0,
                                        'iLatestFlipTurn': 0,
                                        'lLatestRazeData': [-1, -1, -1, -1, -1],
    				    'iRomanVictories': 0,
    				    'lRomanWars': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #total players
                                        #------------AIWars
                                        'lAttackingCivsArray': [0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0],
                                        'iNextTurnAIWar': -1,
                                        #------------Congresses
                                        'bCongressEnabled': False,
                                        'iCivsWithNationalism': 0,
                                        'bUNbuilt': False,
                                        'lInvitedNations': [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False],
                                        'lVotes': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lTempActiveCiv': [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
                                        'lTempReqCity': [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
                                        'iLoopIndex': 0,
                                        'lTempReqCityHuman': [-1, -1, -1, -1, -1],
                                        'tempReqCityNI': -1,
                                        'tempActiveCivNI': -1,
                                        'lTempAttackingCivsNI': [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False],
                                        'iNumNationsTemp': 0,
                                        'lBribe' : [-1, -1, -1],
                                        'lCivsToBribe': [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
                                        'tTempFlippingCityCongress': -1,
                                        'lMemory': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #total players + barbarians (minors and barbs are not used, but necessary for not going out of range)
                                        #------------Plague
                                        'lPlagueCountdown': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #total players + barbarians
                                        'lGenericPlagueDates': [-1, -1, -1, -1],# -1],
                                        'lFirstContactPlague': [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False], #total players + barbarians
                                         #------------Victories
                                        'lGoals': [[-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
    					       [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
    					       [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
    					       [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1],
                                                   [-1, -1, -1]],
                                        'lReligionFounded': [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
                                        'iEnslavedUnits': 0,
                                        'iRazedByMongols': 0,
                                        'lEnglishEras': [-1, -1],
                                        'lGreekTechs': [-1, -1, -1],
                                        'lNewWorld': [-1, -1], #first founded; circumnavigated (still unused)
                                        'iNumSinks': 0,
                                        'lBabylonianTechs': [-1, -1, -1],                                    
                                        #'iMediterraneanColonies': 0,
                                        'iPortugueseColonies': 0,
                                        'iFrenchColonies': 0,
                                        'lWondersBuilt': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'l2OutOf3': [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False],
    				    'iChineseGoldenAges' : 0,
    				    'lItalianTechs': [-1, -1, -1, -1],
    				    'iItalianUniversities': 0,
    				    'iNumKoreanSinks': 0,
                                        #------------Stability
                                        'lBaseStabilityLastTurn': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lPartialBaseStability': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lStability': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lOwnedPlotsLastTurn': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lOwnedCitiesLastTurn': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lCombatResultTempModifier': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lGNPold': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lGNPnew': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lGreatDepressionCountdown': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lStatePropertyCountdown': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lDemocracyCountdown': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                        'lStabilityParameters': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #2+3+2+3+3
                                        'lLastRecordedStabilityStuff': [0, 0, 0, 0, 0, 0], # total + 5 parameters
    				}
                    self.save()
    
    # All modules import the following single instance, not the class
    
    sd = StoredData()
    
     
  2. Leoreth

    Leoreth 古典部の会員 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    32,612
    Gender:
    Male
    Location:
    Kamiyama
    Not sure because I never added a minor civ, but what makes you so certain it's in StoredData? Usually if there's something wrong with the list lengths you'd only get an error if you try to address it with a non-existing index, I think.
     
  3. Linkman226

    Linkman226 #anarchy

    Joined:
    Sep 14, 2007
    Messages:
    2,493
    I figured it out. Answer here
     

Share This Page