Simple Python Things

Well, I just tried it out and you hit it right on the nose. It is the exact spot you mentioned (in this case line 87). Here is the file, I am quite sure you are going to look at this file and think it is horribly put together. ;)
 

Attachments

If you want to look at a horrible file, then look at the CvEventManager in my mod, that's horrible ;). Your's is sure clean and okay :).

Okay, it was intended wrong, i fixed it, file is attached.
 

Attachments

I downloaded the j's file and seems that if you did put them in line, your text editor screwed it. The changes are way too right, and you use spaces instead of tabs.
Here are the first and second parts:
Code:
		###circus hagenbeck start part 1
		self.oldcity = [-1,-1]
		###circus hagenbeck end part 1
Code:
		### circus hagenbeck start part 2
		if (gc.getGame().getGameTurnYear() <> gc.getDefineINT("START_YEAR")):
			for iPlayer in range (gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if player.isAlive():
					numbuildings = player.countNumBuildings(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"))
					if numbuildings>0:
						for iCity in range(player.getNumCities()):
							pCity = player.getCity(iCity)
							if pCity.getNumBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"))>0:
								self.oldcity = [iPlayer,iCity]
			return
		###circus hagenbeck end part 2
Try them.
 
Does this problem happen every time?
Does it only happen with ships, or with normal land untis?
Does the owner of the unit have a capital?

I never had this error before.
In my mod, the Respawn-promotion is not allowed for naval units, so it has to be normal land units.
I suppose every civ has a capital. Babrbs have none. However I checked if I could reproduce the CTD by giving the Respawn-promotion to a barbarian unit, and then destroy it. There was no CTD but only a bunch of Python error pop-ups.
 
I downloaded the j's file and seems that if you did put them in line, your text editor screwed it.

:blush: you're right, i did not see it.


I should not break my own rule: If you did not test it, then it does not work.

I never had this error before.
In my mod, the Respawn-promotion is not allowed for naval units, so it has to be normal land units.
I suppose every civ has a capital. Babrbs have none. However I checked if I could reproduce the CTD by giving the Respawn-promotion to a barbarian unit, and then destroy it. There was no CTD but only a bunch of Python error pop-ups.

Okay...:think:...what python errors do you get, when you disable the line like you described?
 
Thanks NSG, I also noticed that part three seems to be using spaces rather than tabs, can I get a little help on this part:

Code:
###circus hagenbeck start part 3		
		if (CyGame().getTurnYear(iGameTurn)>=1890) and ( iGameTurn % 3 ==0 ):
                        counter = 0
                        while True:
                                counter = counter+1
                                if counter>=100:break
                                dice = gc.getGame().getMapRand()
                                iPlayer = dice.get(gc.getMAX_PLAYERS (), "Players")
                                pPlayer = gc.getPlayer(iPlayer)
                                if pPlayer.isNone():continue
                                if pPlayer.isAlive():
                                        iCity = dice.get(pPlayer.getNumCities () , "Cities" )
                                        pCity = pPlayer.getCity(iCity)
                                        if pCity.isNone():continue
                                        if not pCity.isHasBuilding(gc.getInfoTypeForString("BUILDING_COLOSSEUM")):continue
                                        pCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),1)  

                                        CyInterface().addMessage(iPlayer,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_MOVED",(pCity.getName (),pCity.getName ())),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 
                                        if self.oldcity <>[-1,-1]:
                                                otherplayer = gc.getPlayer(self.oldcity[0])
                                                othercity = otherplayer.getCity(self.oldcity[1])
                                                if not othercity.isNone():
                                                        othercity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),0)
                                                        CyInterface().addMessage(self.oldcity[0],false,20,CyTranslator().getText("TXT_KEY_CIRCUS_LOST",(othercity.getName (),othercity.getName ())),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), othercity.getX(), othercity.getY(), True,True)
                                        self.oldcity = [iPlayer,iCity]                                 
                                        MaxPlayers = gc.getMAX_CIV_PLAYERS ()
                                        for iPlayerNum in xrange(MaxPlayers):
                                            CyInterface().addMessage(iPlayerNum,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_ANNOUNCE",(pCity.getName (),pPlayer.getCivilizationAdjective (1) )),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 
                                        
                                        break
###circus hagenbeck end part 3
 
Thanks NSG, I also noticed that part three seems to be using spaces rather than tabs, can I get a little help on this part:

Oh, somehow I missed that one. This should work:
Code:
###circus hagenbeck start part 3		
		if (CyGame().getTurnYear(iGameTurn)>=1890) and ( iGameTurn % 3 ==0 ):
			counter = 0
			while True:
				counter = counter+1
				if counter>=100:break
				dice = gc.getGame().getMapRand()
				iPlayer = dice.get(gc.getMAX_PLAYERS (), "Players")
				pPlayer = gc.getPlayer(iPlayer)
				if pPlayer.isNone():continue
				if pPlayer.isAlive():
					iCity = dice.get(pPlayer.getNumCities () , "Cities" )
					pCity = pPlayer.getCity(iCity)
					if pCity.isNone():continue
					if not pCity.isHasBuilding(gc.getInfoTypeForString("BUILDING_COLOSSEUM")):continue
					pCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),1)  

					CyInterface().addMessage(iPlayer,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_MOVED",(pCity.getName (),pCity.getName ())),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 
					if self.oldcity <>[-1,-1]:
						otherplayer = gc.getPlayer(self.oldcity[0])
						othercity = otherplayer.getCity(self.oldcity[1])
						if not othercity.isNone():
							othercity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),0)
							CyInterface().addMessage(self.oldcity[0],false,20,CyTranslator().getText("TXT_KEY_CIRCUS_LOST",(othercity.getName (),othercity.getName ())),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), othercity.getX(), othercity.getY(), True,True)
					self.oldcity = [iPlayer,iCity]                                 
					MaxPlayers = gc.getMAX_CIV_PLAYERS ()
					for iPlayerNum in xrange(MaxPlayers):
						CyInterface().addMessage(iPlayerNum,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_ANNOUNCE",(pCity.getName (),pPlayer.getCivilizationAdjective (1) )),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 

					break
###circus hagenbeck end part 3
But you should test it so it does work. I tested it and got no errors.
 
@Strategyonly: No, no idea what's going on.
I have to remember to download your mod, so that you can give me a savegame and see it myself.

@hrochland:
- In your XML is an error, you have no entry for DCCOURTHOUSE in your BuildingsInfos.xml
- And you should set iConquestProb for the courthouses to 100, else you will sometimes not get a courthouse.



One problem here: The python code can't see, why a capital has been moved.
Example:
- You capture Washington, new capital will be Philadelphia (or so).
- America decides to build the capital new in Philadelphia, because it's just better.
For python, both is the same, it can't see a difference, why it was moved.

It can be made so, that you can only capture the white house, when you capture the first found city, when it is a capital. That can be done relativly easy. So in the second example, you would not get the white house, when you capture one of your cities.


....but man, i have an easier suggestion, with no python.
- Make a new wonder, white house
- And make it a free building class for america, like this here (in CivilizationInfos.xml):
PHP:
			<FreeBuildingClasses>
				<FreeBuildingClass>
					<BuildingClassType>BUILDINGCLASS_PALACE</BuildingClassType>
					<bFreeBuildingClass>1</bFreeBuildingClass>
				</FreeBuildingClass>
			</FreeBuildingClasses>
- Then america will start with a palace and the white house. Or you can just make them start with only the white house.
- The white house will at the beginning be in the capital.
- If it's a wonder, it can't be moved
- It will not be moved, when you capture the capital

Is way easier, i think :), and will do, what you want.



Another thing: I'm out of modding for the next 2 or 3 weeks.
Semester holidays, and i'll stay for that time at my parents, without my gaming pc. So don't expect anything new from me. I'll sure be here for answering questions, but i can't test anything or fix more complicated errors.

Good idea, thanks. I have four palaces by your way and will make next
Thanks
 
It is not working here is my files!

What does not work?
Does just nothing happen?
Do you get a python exception (are python exceptions turned on?)?
Are all the files in the proper place (because it will not work, if they are all in the same folder like in thze .zip).
 
I've re-uploaded the "SpawnACiv" modcomp. I've added 2 tags to add a type of unit only to the capital of the new civ and to control the amount of it.
It was, long time ago, requested by Cybrxkhan.

--------------------------------------------------------------------


And i've added another small modcomp, not great, but i wanted to do it:

Believer Trait

Spoiler :
believertrait_rhi.jpg


With this trait, new cities of the leader will automatically have the state religion and the temple of the state religion.

There's only one change in CvEventManager, and it's labeled with "Believer Trait".
2 XML files are included, one for the text, and the CivilizationInfos.xml for an example.

It might be overpowered, but you're free to change it ;).



-------------------------

Another point, @cybrxkhan: I've looked at the units religion modcomp, and this thing seems way to complicated for me :(.
It's not really soooo big, but big enough if you don't know, where to begin.
Sorry, i will not update it.
 
What does not work?
Does just nothing happen?
Do you get a python exception (are python exceptions turned on?)?
Are all the files in the proper place (because it will not work, if they are all in the same folder like in thze .zip).

I think I know what the problem is.I am not an Admin on my computer so my Mod is in the MODS
folder!!! Could this be the problem?
Code:
	   ###spawn a civ part 2 start###
                MyFile=open("Mods/The Ancient, Classical, and Dark ages Mod/Assets/XML/CustomXML/CIV4SpawnCivInfos.xml")
                SpawnCivUtil.ReadMyFile(MyFile)                        
                MyFile.close()
                ###spawn a civ part 2 end###

Code:
	   ###spawn a civ part 3 start###
		MyFile=open("Mods/The Ancient, Classical, and Dark ages Mod/Assets/XML/CustomXML/CIV4SpawnCivInfos.xml")
                SpawnCivUtil.ReadMyFile(MyFile)                        
                MyFile.close()
                ###spawn a civ part 3 end###
 
Another point, @cybrxkhan: I've looked at the units religion modcomp, and this thing seems way to complicated for me :(.
It's not really soooo big, but big enough if you don't know, where to begin.
Sorry, i will not update it.

No problem. Although I am a bit sad, it wasn't one of those features where "IF THIS IS NOT IN MY ENTIRE MOD WILL BE A COMPLETE FAILURE! NOOOOO!!!" kind of thing, so don't worry about it, I'm glad that you at least tried and managed to make a modcomp similar to it.

Also thanks for the update to the SpawnACiv modcomp!
 
I think I know what the problem is.I am not an Admin on my computer so my Mod is in the MODS
folder!!! Could this be the problem?
Code:
	   ###spawn a civ part 2 start###
                MyFile=open("Mods/The Ancient, Classical, and Dark ages Mod/Assets/XML/CustomXML/CIV4SpawnCivInfos.xml")
                SpawnCivUtil.ReadMyFile(MyFile)                        
                MyFile.close()
                ###spawn a civ part 2 end###

Code:
	   ###spawn a civ part 3 start###
		MyFile=open("Mods/The Ancient, Classical, and Dark ages Mod/Assets/XML/CustomXML/CIV4SpawnCivInfos.xml")
                SpawnCivUtil.ReadMyFile(MyFile)                        
                MyFile.close()
                ###spawn a civ part 3 end###

Yes, that is definetly the problem.
No real mods should go into My Documents, so i have never thought about it.

If you still want to use it, then you have to put in there the complete path to your mod, meaning C:\Documents and Settings\[UserName]\My Documents\etc.

But it can't be published like that...then the path should be grabbed out of the registry...:think: no, that's a bit complicated.
And it would not work for every experienced user here, because no one of them would put a mod into My Documents.

No problem. Although I am a bit sad, it wasn't one of those features where "IF THIS IS NOT IN MY ENTIRE MOD WILL BE A COMPLETE FAILURE! NOOOOO!!!" kind of thing, so don't worry about it, I'm glad that you at least tried and managed to make a modcomp similar to it.

Also thanks for the update to the SpawnACiv modcomp!

I'm glad, that you're not too disappointed :).
But yes, i also would like to see this modcomp to be updated, but well, i just can't :/.



-------------------------
I've adapted the Civilopedia: Invisible dummy techs to the sevopedia, because Cybah requested it for his BASE mod. The download can be found here.
 
Yes, that is definetly the problem.
No real mods should go into My Documents, so i have never thought about it.

If you still want to use it, then you have to put in there the complete path to your mod, meaning C:\Documents and Settings\[UserName]\My Documents\etc.

But it can't be published like that...then the path should be grabbed out of the registry...:think: no, that's a bit complicated.
And it would not work for every experienced user here, because no one of them would put a mod into My Documents.

I will get My Admin to change it to a Mod not a MOD
:thanx:
I still Love this ModComp :trophy:
 
Believer trait will be very useful in my mod. Thanks for uploading, these small accesible comps are exactly what us neophyte python modders crave!
 
Just a question - does the believer trait work for captured cities? If not, is it easy to modify so that it does?

BTW; thanks for making all of this. Having great stuff which SDK-illiterates can merge into their mods is a godsend.
 
Back
Top Bottom