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

Need Help Making Conditional Spawns in RFC

Discussion in 'Rhye's and Fall Modmods' started by mrrandomplayer, Sep 2, 2013.

  1. mrrandomplayer

    mrrandomplayer Potentially back

    Joined:
    Aug 1, 2012
    Messages:
    3,305
    Location:
    A point in the time-space continuum
    I am right now trying to make a modmod for RFC that makes certain civs conditional. I'm a pretty awful programmer and I mostly copy-pasted the DoC conditional spawn coding into the RhyesandFall.py. When I opened it up, I got a bajillion errors, most of them not even in the python file I edited. Could someone please tell me what I did wrong and tell me how to fix it?

    From part of the initBirth function:
    Code:
    def initBirth(self, iCurrentTurn, iBirthYear, iCiv):
                    iHuman = utils.getHumanID()
                    if (iCurrentTurn == iBirthYear-1 + self.getSpawnDelay(iCiv) + self.getFlipsDelay(iCiv)):
    
                            if (iCurrentTurn >= con.tBirth[iVikings]-1 and iCurrentTurn <= con.tBirth[iTurkey]-1):
                                    self.processConstantinople()
                            if (iCurrentTurn >= con.tBirth[iEngland]-1 and iCurrentTurn <= con.tBirth[iMali]-1):
                                    self.processAfrica()
                        
                            tCapital = tCapitals[iCiv]
                            tTopLeft = tCoreAreasTL[iCiv]
                            tBottomRight = tCoreAreasBR[iCiv]
                            tBroaderTopLeft = tBroaderAreasTL[iCiv]
                            tBroaderBottomRight = tBroaderAreasBR[iCiv]                    
                            if (self.getFlipsDelay(iCiv) == 0): #city hasn't already been founded
    
    				# mrrandomplayer: extra checks for conditional civs
    				lConditionalCivs = [iSpain, iFrance, iPortugal, iTurkey, iAmerica]
    					if iCiv in lConditionalCivs and utils.getHumanID() != iCiv:
    
    					if iCiv == iSpain;
    						if iRome in bSpain:
    							if utils.getStability(iRome) >= 20:
    								return
    						else if iCarthage in bSpain:
    							if utils.getStability(iCarthage) >= 20:
    								return
    
    					if iCiv == iFrance:
    						if iRome in tFrance:
    							if utils.getStability(iRome) >= 20:
    								return
    
    					if iCiv == iPortugal:
    						if not pSpain.isAlive:
    							return
    
    					if iCiv == iTurkey:
    						if utils.getStability(iArabia) >= 20:
    							return
    
    					if iCiv == iAmerica:
    						iColonyPlayer = utils.getColonyPlayer(iCiv)
    						if iColonyPlayer < 0: return
    						elif iColonyPlayer not in tNCAmerica:
    							if utils.getStability(iColonyPlayer) >= 20:
    								return
    
     
  2. srpt

    srpt Deist

    Joined:
    May 10, 2010
    Messages:
    2,025
    Location:
    Toronto
    there are some things in your quote that don't make sense, like:

    if iRome in bSpain:

    what is bSpain? if it is a boolean, as indicated by the "b", then it cannot have anything "in" it. also, you haven't defined bSpain anyway. all those bajillion errors actually need to be read and understood. it doesn't matter which file they are in, many files affect each other.
     
  3. Leoreth

    Leoreth 古典部の会員 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    32,460
    Gender:
    Male
    Location:
    Kamiyama
    First of all, most errors you see likely come from the file you have edited. The Python exception screen lists all the methods that have been called until the error has been reached, so the lowest entry is where your problem actually is.

    Some errors I've seen:

    1. You need to indent (add one tab) the code after every if-clause. The general rule is an additional tab for every colon.

    2. At least one of your if statements ends with a semicolon which is invalid in Python.

    3. As srpt said, bSpain, tFrance etc. doesn't mean anything if you don't define them. You probably want to check if there's a Roman city in Spain etc. For this you need to get all Roman cities and check whether they're within the cores of these civs as defined in Consts.py. DoC has some handy utility methods for these jobs but I think in RFC you mostly have to do this by hand.
     

Share This Page