Tsentom1 Python Wonders

Damn, if The_J can't see it I don't know what to do then.

I suppose I should start at square one here: Can anybody confirm that the Topkapi Palace works the way it is intended?
 
I think he meant that in your first attached pic after your red line there is another line. Actually in the same line, just scroll right.
So tabbing cannot possibly work ok in that part of the program...
 
Well it isn't like that in the actual code, I guess I just messed up when I posted it. Here is a direct screen-shot of the code I used:

Spoiler :


Hopefully that is helpful.

Anything you notice, anything, maybe an incorrect indentation would be awesome. I REALLY need to get this to work.
 

Attachments

  • FlavianCode.jpg
    FlavianCode.jpg
    116.1 KB · Views: 519
And for comparison-sake, this is the code (I think it is at least) from GIR's Flavian Amphitheatre wonder:

Code:
	def onUnitBuilt(self, argsList):
		'Unit Completed'

		pCity = argsList[0]
		pUnit = argsList[1]
		pPlayer = gc.getPlayer(pUnit.getOwner())

		if ( pCity.getNumActiveBuilding(gc.getInfoTypeForString('BUILDING_FLAVIAN_AMPHITHEATRE'))==true ):

			### FA_chance = Chance in % to get a Unique Unit (UU) of the same Unitclass instead of the Standart Unit (SU) ###
			FA_chance = 50

			chance = CyGame().getSorenRandNum(100, "Random for UU")
			if (chance < FA_chance):

				iUnitClassType = pUnit.getUnitClassType()

				### Same UnitClass (UC) = UUs and/or EDUs ###
				lgleicheUC = []
				for i in range(gc.getNumUnitInfos()):
					if ( gc.getUnitInfo(i).getUnitClassType() == iUnitClassType ):
						lgleicheUC.append(i)
				if ( len(lgleicheUC) >= 2 ):

		 			### Choose the UnitClass UU (lgleicheUC[0] = Standard Unit) ###
					chance = CyGame().getSorenRandNum(len(lgleicheUC) - 1, "Random for UU")
					iNewUU = lgleicheUC[chance + 1]

					### Check (not replace UU with same UU) ###
					iUnitType = pUnit.getUnitType()
					if ( iUnitType != iNewUU ):

						### Create/Converte Unit ###
						iX = pUnit.getX()
						iY = pUnit.getY()
						pNewUnit = pPlayer.initUnit( iNewUU, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION )
						pNewUnit.convert(pUnit)
	### Ausgabe ###
						UnitInfo = gc.getUnitInfo(iUnitType)
						UnitInfo2 = gc.getUnitInfo(iNewUU)
						CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_FLAVIAN_AMPHITHEATRE_GAMETXT1",( pCity.getName(), UnitInfo2.getDescription(), UnitInfo.getDescription() )),'',0,'art/Interface/Buttons/Buildings/Flavian.dds',ColorTypes(11),iX,iY,True,True)
						### message: In %s1 the Flavian Amphitheatre provides a %s2 instead of a %s3 ###

I guess what I'm wondering here is if this code could work too, or if it is better or what. I'm confused. :crazyeye:
 
I hate to triple post here, but I think it is better to keep a bunch of different code in different posts just to avoid confusion. Anyway, I'm an idiot because I missed two other sections of code. So I'm going to put them in, but I wanted to see what needs to be removed to fit with my other code (i.e. so there is no vassal requirement). So here is the first section I missed:

Code:
	def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		iGameTurn, iPlayer = argsList

## Topkapi Palace Start ##

		pPlayer = gc.getPlayer(iPlayer)
		iTeam = pPlayer.getTeam()
		pTeam = gc.getTeam(iTeam)

		b_Flavian = gc.getInfoTypeForString("BUILDING_FLAVIAN")
		obsoleteTech = gc.getBuildingInfo(b_Topkapi).getObsoleteTech()

		if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ppCity.getNumActiveBuilding(b_Flavian) == true:

					for iPlayer in range(gc.getMAX_PLAYERS()):
						ppPlayer = gc.getPlayer(iPlayer)
						if ( (ppPlayer.isAlive()==true) and (ppPlayer.isBarbarian()==false) ):
							if ( gc.getTeam(ppPlayer.getTeam()).isVassal(iTeam) == true ):

								iGold = ppPlayer.getGold( )
								if ppPlayer.getGold( ) >= 5000:
									ppPlayer.changeGold( 50 )
								if ppPlayer.getGold( ) < 5000:
									if ppPlayer.getGold( ) >= 100:
										ppPlayer.changeGold( iGold//50 )
									else:
										ppPlayer.changeGold( 2 )

								ppPlayer.changeCombatExperience( +1 )
	
## Topkapi Palace End ##

Okay, the second part is a bit confusing because I have a section similar in my code already. Here is the Topkapi code:

Code:
## Topkapi Palace Start ##

	def getRandomNumber(self, int):
		return CyGame().getSorenRandNum(int, "Gods")

## Topkapi Palace End ##

And here is what I have in mine, which has the same "def" part, but a different return:

Code:
	def getRandomNumber(self, int):
		return gc.getGame().getSorenRandNum(int, "Next War")

So yeah, a little help here; how do I "merge" these last two codes. Hopefully this should make it all work... right?
 
Aaaaah. No! Don't believe any of the error screens you are showing us. You should really show us the python error screens which are UNDER your error screens. The "NAME" which is mentioned in the error screen must be where you put in the code. This has nothing do to with diplomacy or the BUG mod.
 
You do not need to merge them. One is enough. It just tells you, that you can use

"getRandomNumber(X)" instead of "CyGame().getSorenRandNum(X, "ANYTHING HERE")"

it's shorter. that's all.
 
Aaaaah. No! Don't believe any of the error screens you are showing us. You should really show us the python error screens which are UNDER your error screens. The "NAME" which is mentioned in the error screen must be where you put in the code. This has nothing do to with diplomacy or the BUG mod.

I don't understand, I did that alraedy. Here are all of the pop-ups, the first one and the two underneath.


And the other code I posted is for strengthening vassals, so we can simply ignore that. So I don't know what to do.
 
LOL.

Alright, I just want to point out to both of you (NSG, and Cybah) that both of the things you just asked me for have already been posted here:

.....

Unfortunately I still got these pop-ups at around turn two or three:


So I'm not sure what the problem coudl really be at this point. But judging by the pop up it appears that line 239 seems to be at issue. Line 239, however, has nothing to do with this code (but didn't cause any issues until this code was used). So I might need some help on this. Here is the surrounding code with line 239 hilighted:

Code:
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]
		###from here
		[COLOR="Red"]pPlayer = gc.getPlayer(iPlayer)[/COLOR]
		if not pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_SLAVERY")):
			iSlaveSpecialist = gc.getInfoTypeForString("SPECIALIST_SLAVE")
			iSlaveSpecialistInCity = pCity.getSpecialistCount(iSlaveSpecialist)
			pCity.alterSpecialistCount(iSlaveSpecialist,-iSlaveSpecialistInCity)
				###to here
		
# no anger defying UN resolutions start #
		iGovernmentCivicOption = CvUtil.findInfoTypeNum(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_GOVERNMENT')
		iPoliceState = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_POLICE_STATE')
		pPlayer = gc.getPlayer(iPlayer)
		iGovernmentCivic = pPlayer.getCivics(iGovernmentCivicOption)

		if (iGovernmentCivic == iPoliceState):
			pCity.changeDefyResolutionAngerTimer(pCity.getDefyResolutionAngerTimer())
# no anger defying UN resolutions end #

Do you guys see anything?
 
You mean the "bug" error screen is the last? It looks like there is another screen behind that screen.

Anyway, try this instead of your highlighted line:

PHP:
		pPlayer = gc.getPlayer(pCity.getOwner())
 
You mean the "bug" error screen is the last? It looks like there is another screen behind that screen.

Anyway, try this instead of your highlighted line:

PHP:
		pPlayer = gc.getPlayer(pCity.getOwner())

Thanks, I'll try that out. :goodjob:

Oh, the screen behind the BUG screen just says "Traceback error, most recent call last" or something like that, so I didn't bother posting it.
 
This error really confuses me :confused:.
There is just nothing wrong :confused:.

Damn, if The_J can't see it I don't know what to do then.

It does not mean anything ;). In fact, i'm a terrible coder, you just can't see it ;).
 
Hm. I've read everything and quit puzzled.
I have the Eden Project and it works fine : video and all.
But the Copernicus, Sphinx, the Greath Bath of Mahenjo-Daro and Cheomseongdae movies don&#8217;t work. They are work great ingame but the movies won&#8217;t show up at all.
Any idea ?
 
Golden Dawn download link is still borked. Just a heads up. Thank you for the shiny wonders.
 
Does anyone else have the problem with the Public Works wonder where Infrastructure can always be built by anyone at any time?

You should have fixed it in the meanwhile. If not, just my 2 cent: I guess you did not update PythonCallbackDefines.xml - or CvGameUtils.py.
 
Hi!

I hope some Python-knowing people can help me. I would like to see a message each time KingRichards grants a Crusader. Something like: "A new Crusader has joined your cause.".

Unfortuneately, I have no idea how to do this. So please help.:help:

Chamaedrys
 
If you look through the python files of this mod, you'll see multiple times this line here:
PHP:
pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )

Add directly in the line afterwards:
PHP:
CyInterface().addMessage(iPlayer,False,15,CyTranslator().getText("TXT_KEY_YOUR_NEW_PERSONAL_TEXT",()),'',0,gc.getUnitInfo(u_crusader).getButton (),ColorTypes(44), iX, iY, True,True)

Attention: This line needs exactly the same amount of white spaces like the line before.
Don't put them in by hand, copy the whitespaces from the line before! Might sound strange, but this is needed.
Please activate the python exceptions in your BtS .ini to see, if your modifications work or not.
And don't forget to create and change TXT_KEY_YOUR_NEW_PERSONAL_TEXT ;).
 
Top Bottom