Scrolling Civics screen help

What does "pPlayer.getStateReligion()" return if they have no state religion?

That shouldn't happen, because the unit needs a state religion.

If not, then something hasn't been merged right.
But seems the be the only possibility :crazyeye:.
 
What does "pPlayer.getStateReligion()" return if they have no state religion?

I think it is "-1" (ReligionTypes.NO_RELIGION). The list has no index of -1, it starts at 0 for "JEWISH". You should prefix the last 4 lines with a check for state religion not being -1, something like this:
Code:
        		if (iReligion != -1) :        		
        			MonasteryName = "BUILDING_"+NumReligion[iReligion]+"_MONASTERY"
        			bMonastery = gc.getInfoTypeForString(MonasteryName)
        			if (city.getNumRealBuilding(bMonastery)==True) :
        				unit.changeExperience(2,100,False,False,False)

If you want to remember why you check for -1, you could use the defined value ReligionTypes.NO_RELIGION instead.

You may need to extend the block (increase the indentation level) for lines after that if they are part of the same general thing.

By the way, the lines in your code all use tabs for indentation except the last one. That one uses spaces. Mixing them is a bad plan. (I changed it to tabs in my version above.)

Edit: Oops. I have to modify that - it looks like the first lines I copied above use a mix of tabs and spaces. The earlier lines use spaces just like the last line did, except for the blank line (which doesnt' matter) and the line before it both of which seem to have some tabs and spaces. This is still a bad idea. Very bad. The level of indentation is important, and mixing the two can make it look like they are indented the same amount when they are not (it is the number of characters, not the visual appearance, which matters).

That shouldn't happen, because the unit needs a state religion.

If not, then something hasn't been merged right.
But seems the be the only possibility :crazyeye:.

Nope it didnt work, i still get the error???:(

Would it make a difference if i didnt use the PythonCallbackDefines?
 
Are you sure you get the same error?

Oh wow your right the last line changed from 848 to 849? sorry.


Traceback (most recent call last):

File "CvEventInterface", line 25, in onEvent

File "CvCustomEventManager", line 143, in handleEvent

File "CvCustomEventManager", line 154, in _handleDefaultEvent

File "CvEventManager", line 849, in onUnitBuilt

Code:
if (iReligion != -1) :        		
        			MonasteryName = "BUILDING_"+NumReligion[iReligion]+"_MONASTERY"
        			bMonastery = gc.getInfoTypeForString(MonasteryName)
        			if (city.getNumRealBuilding(bMonastery)==True) :
        				unit.changeExperience(2,100,False,False,False)

IndexError: list index out of range
ERR: Python function onEvent failed, module CvEventInterface

for some reason if (iReligion != -1) : is to the far left, but in the python file itself its not??
 
Have you added religions to this mod? If so, you need to add them to that list NumReligion being created just above the breaking line.
 
Have you added religions to this mod? If so, you need to add them to that list NumReligion being created just above the breaking line.

Yeppers, now i get this?

Traceback (most recent call last):
File "<string>", line 1, in ?
File "<string>", line 52, in load_module
File "CvEventInterface", line 13, in ?
File "<string>", line 52, in load_module
File "CvCustomEventManager", line 24, in ?
File "<string>", line 35, in load_module
File "<string>", line 13, in _get_code
File "CvEventManager", line 845
NumReligion.append('ZOROASTRIAN')
^
SyntaxError: invalid syntax
load_module CvAppInterface

Spoiler :
Code:
###WarriorsOfGod Fanatic Part2 Start ###		
		strUnit = gc.getUnitInfo(unit.getUnitType()).getType()
		CurrentUnit = gc.getInfoTypeForString(strUnit)
		if (CurrentUnit == gc.getInfoTypeForString("UNIT_FANATIC")):
                        iPlayer = city.getOwner()
                        pPlayer = gc.getPlayer(iPlayer)
        		iReligion = pPlayer.getStateReligion()
        		NumReligions = 16
        		for i in range (NumReligions):
                            if ((city.isHasReligion(i)==True) and (i<>iReligion)):
                                unit.changeExperience(2,100,False,False,False)
###WarriorsOfGod Fanatic Part2 End ###
###WarriorsOfGod Monk Part2 Start ###		
		strUnit = gc.getUnitInfo(unit.getUnitType()).getType()
		CurrentUnit = gc.getInfoTypeForString(strUnit)
		if (CurrentUnit == gc.getInfoTypeForString("UNIT_MONK")):
                        NumReligion = []
                        NumReligion.append('JEWISH')
                        NumReligion.append('CHRISTIAN')
                        NumReligion.append('ISLAMIC')
                        NumReligion.append('HINDU')
                        NumReligion.append('BUDDHIST')
                        NumReligion.append('CONFUCIAN')
                        NumReligion.append('TAOIST')
	        NumReligion.append('HELLENIC')
                        NumReligion.append('ZOROASTRIAN')
                        NumReligion.append('SHINTO')
                        NumReligion.append('CANNIBALISM')
                        NumReligion.append('NORSE')
                        NumReligion.append('EGYPT_MYTHOLOGY')
                        NumReligion.append('VOODOO')
	        NumReligion.append('TENGRIISM')
                        NumReligion.append('LEVANT')	
                        iPlayer = city.getOwner()
                        pPlayer = gc.getPlayer(iPlayer)
        		iReligion = pPlayer.getStateReligion()
        		        		
        		if (iReligion != -1) :        		
        			MonasteryName = "BUILDING_"+NumReligion[iReligion]+"_MONASTERY"
        			bMonastery = gc.getInfoTypeForString(MonasteryName)
        			if (city.getNumRealBuilding(bMonastery)==True) :
        				unit.changeExperience(2,100,False,False,False)
                            
                        TempleName = "BUILDING_"+NumReligion[iReligion]+"_TEMPLE"
        		bTemple = gc.getInfoTypeForString(TempleName)        		
        		if (city.getNumRealBuilding(bTemple)==True) :
                            unit.changeExperience(2,100,False,False,False)

                        CathedralName = "BUILDING_"+NumReligion[iReligion]+"_CATHEDRAL"
        		bCathedral = gc.getInfoTypeForString(CathedralName)        		
        		if (city.getNumRealBuilding(bCathedral)==True) :
                            unit.changeExperience(2,100,False,False,False)

                        ShrineName = "BUILDING_"+NumReligion[iReligion]+"_SHRINE"
        		bShrine = gc.getInfoTypeForString(ShrineName)        		
        		if (city.getNumRealBuilding(bShrine)==True) :
                            unit.changeExperience(4,100,False,False,False)

                        ApostolicPalace = gc.getInfoTypeForString("DIPLOVOTE_POPE")
                        if ((pPlayer.isFullMember(ApostolicPalace)==True)and (CyGame().isDiploVote(ApostolicPalace)==True)):
                            unit.changeExperience(4,100,False,False,False)


                        
###WarriorsOfGod Monk Part2 End ###


Now if i take the
NumReligion.append('HELLENIC')
NumReligion.append('ZOROASTRIAN')
NumReligion.append('SHINTO')
NumReligion.append('CANNIBALISM')
NumReligion.append('NORSE')
NumReligion.append('EGYPT_MYTHOLOGY')
NumReligion.append('VOODOO')
NumReligion.append('TENGRIISM')
NumReligion.append('LEVANT')

back out, it has NO errors (when i LOAD the game)?? Then ingame i get 850 etc

So i am just deleting the WarriorsOfGod from the python, sorry The_J it's just giving me too many errors with whitespacing. I dont understand it either cause i used WinMerge only.
 
Now that i took out that i get this error? what the heck?

Traceback (most recent call last):
File "CvEventInterface", line 25, in onEvent
File "CvCustomEventManager", line 143, in handleEvent
File "CvCustomEventManager", line 154, in _handleDefaultEvent
File "CvEventManager", line 1109, in onCityGrowth

Spoiler :
Code:
def onCultureExpansion(self, argsList):
		'City Culture Expansion'
		pCity = argsList[0]
		iPlayer = argsList[1]
		CvUtil.pyPrint("City %s's culture has expanded" %(pCity.getName(),))
	
	def onCityGrowth(self, argsList):
		'City Population Growth'
		pCity = argsList[0]
		iPlayer = argsList[1]
		[B]CvUtil.pyPrint("%s has grown" %(pCity.getName(),))[/B]
	
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]

		CvAdvisorUtils.cityAdvise(pCity, iPlayer)

File "CvUtil", line 127, in pyPrint

Code:
def pyPrint(stuff):
	stuff = 'PY:' + stuff + "\n"
	[B]sys.stdout.write(stuff)[/B]

def pyAssert(cond, msg):
	if (cond==False):
		sys.stderr.write(msg)
	assert(cond, msg)

File "<string>", line 13, in write
UnicodeEncodeError
:
'ascii' codec can't encode character u'\xc9' in position 3: ordinal not in range(128)

ERR: Python function onEvent failed, module CvEventInterface
 
The lines for HELLENIC and TENGRIISM appear to be indented less thant he others. In fact, they appear to be at the same level of indentation as the "if (CurrentUnit..." line which means that when it hit the line appending HELLENIC to the list it bailed out of the if block - that line and every other line after it is no longer inside the if-block and is run every time the function is run. One problem that this causes is that the list is initilaized ("NumReligion = []") inside the if-block, so if the function is run and the unit is not a UNIT_MONK it tries to use NumReligion.append() which doesn't exist since it was never initialized as a list.

The stuff shown on this board delimited by the code tags happens to have tab stops set to 8, which is (I think) the only setting where spaces and tabs actually match in indentation level in python (if my limited understanding of how the python uindentation works is right - I think it replaces tabs with 1 to 8 spaces to make the length of the line up to that tab be an even multiple of 8 characters; this is the same as what you see using a tab stop setting of 8). So, if the indentation looks wrong when posted to a code area here, it is probably wrong.

As for the pyPrint thing, it looks like you have a city with a name using a capital E with an accent over it (give or take - that's what character c9, in hex, is in the extended ascii character set used by windows).
 
File "CvWBDesc", line 470, in write

At this line in CvWBDesc.py (in the BtS assets folder, down in python/pyWB) it is trying to write out the civilization's art style type.
Code:
			f.write("\tArtStyle=%s\n" %(gc.getArtStyleTypes(gc.getPlayer(idx).getArtStyleType())))

It tries to write out this data for any player (over all player slots, not just active players) who has a civilization type set.

I'm not sure how you could get a bad art style type except not having one in the CIV4CivilizationInfos.xml. The UnitArtStyleType tag must have a valid value like UNIT_ARTSTYLE_EUROPEAN. The only other thing I can think of is if you are loading the game from a worldbuilder save that has been edited such that this data is bad for some civ.
 
At this line in CvWBDesc.py (in the BtS assets folder, down in python/pyWB) it is trying to write out the civilization's art style type.
Code:
			f.write("\tArtStyle=%s\n" %(gc.getArtStyleTypes(gc.getPlayer(idx).getArtStyleType())))

It tries to write out this data for any player (over all player slots, not just active players) who has a civilization type set.

I'm not sure how you could get a bad art style type except not having one in the CIV4CivilizationInfos.xml. The UnitArtStyleType tag must have a valid value like UNIT_ARTSTYLE_EUROPEAN. The only other thing I can think of is if you are loading the game from a worldbuilder save that has been edited such that this data is bad for some civ.

Thx for the info, i found out i left some lines out of the CvEventManager that needed to be in there.
 
As God-Emperor stated, your indentation doesn't look like it's matching. Why you get a SyntaxError instead of an IndentationError, I have no idea. In any case, the solution is simple:

Never mix tabs and spaces for indentation!

Pick one of the other and stick to it.
 
So i am just deleting the WarriorsOfGod from the python, sorry The_J it's just giving me too many errors with whitespacing. I dont understand it either cause i used WinMerge only.

I'll redo it in a more intelligent way, so that this will not happen.
 
Back
Top Bottom