The "Don't Be Scared of the" Python Playpen Thread

I'm not getting any attitude changes from the Lotus Temple. Can anyone see anything wrong with the code?
Code:
## Lotus Start ##
	if iBuildingType == gc.getInfoTypeForString( 'BUILDING_LOTUS' ):
		pPlayer = gc.getPlayer(pCity.plot().getOwner())
		pPID = pPlayer.getID()
		iTeam = pPlayer.getTeam()
		for iPlayer2 in range(gc.getMAX_CIV_PLAYERS()):
			pPlayer2 = gc.getPlayer(iPlayer2)
			if (pPlayer2.isAlive()==True) and (pPlayer2.isBarbarian()==False):
				if pPlayer2.AI_getAttitude(pPID) < 2:
					for i in range (1,200,1):
						pPlayer2.AI_changeAttitudeExtra(iTeam, +1)
						if pPlayer2.AI_getAttitude(pPID) == 2:
							break
## Lotus End ##

As you know I'm moderately to highly clueless vis a vis Python, but I did wonder why it is checking the player attitude, while incrementing the team attitude. :confused:

ETA: Checking now whether it's even called BUILDING_LOTUS...
ETA2: Umm no it isn't so that's one problem found! :lol:
 
It is simply coding error. Both should take in (int player ID)
 
It is simply coding error. Both should take in (int player ID)

So:
pPlayer2.AI_changeAttitudeExtra(pPID, +1)

is all that needs changing?
 
Will work, but that is a pretty outdated code with some inefficiencies.
You might as well rewrite it.
 
@Yudishtira are you going to do this?

I was going to down load the latest version by Platyping and see what the differences are, besides the bit where we use BUG Modular Python.
 
@Yudishtira are you going to do this?

I was going to down load the latest version by Platyping and see what the differences are, besides the bit where we use BUG Modular Python.

I've made the two fixes mentioned above in my assets here, and so far it doesn't seem to be working.

As for a more complete rework, I have no ambitions in that direction. Please carry on with what you had planned to do...
 
I not sure if I uploaded a newer version.
It is pretty much one of my earliest works which is done with amateur skills.
The for loop with range 200 for instance can be rewritten with a while loop in a cleaner way.
 
The effects was swapped with Project Utopia.
 
@Yudishtira I think I have fixed this. Part of the problem was that you have to change the attitude of player1 with player2 and then player2 with player1.

I reused the relevant part of Platyping's Project Utopia code.
 
Top Bottom