Need help fixing a code

Jarlaxe Baenre

Emperor
Joined
Feb 17, 2010
Messages
1,959
Location
Calgary, Alberta, Canada
I can't figure out what's wrong with this code. It's for an RFC modmod I'm making. It's supposed to give Germany 1 food and 1 hammer on every land tile. There's a building I've created that has a description of ' ' and gives the 1 food and hammer. I believe the problem is in the code.

Code:
## BEGIN HRE UP - Fake Buildings ##

		pPlayer = gc.getPlayer(city.getOwner())

		iBuildingHRE= gc.getInfoTypeForString('BUILDING_HRE_UP')

		getCivilizationType ()
			if (CivilizationType ('CIVILIZATION_GERMANY')):
			pCity.setNumRealBuilding(iBuildingHRE, 1)
		else:
			if pCity.getNumActiveBuilding(iBuildingHRE) > 0:
				pCity.setNumRealBuilding(iBuildingHRE, 0)
				

## END HRE UP - Fake Buildings ##
 
Please turn on logging and python exceptions, and you will see numerous errors in this code. At least, you have some incorrect indentation and some undefined variables.
 
To which function is the code attached to?


PHP:
## BEGIN HRE UP - Fake Buildings ##

		pPlayer = gc.getPlayer(city.getOwner())

		iBuildingHRE= gc.getInfoTypeForString('BUILDING_HRE_UP')

		if pPlayer.getCivilizationType () == gc.getInfoTypeForString("CIVILIZATION_GERMANY"):

			pCity.setNumRealBuilding(iBuildingHRE, 1)
		else:
			pCity.setNumRealBuilding(iBuildingHRE, 0)			
				

## END HRE UP - Fake Buildings ##

this is probably "more right".
 
To which function? You mean what is it supposed to do? It's supposed to create a building in every city Germany builds that adds 1 food and 1 hammer to each land tile (Excluding mountains)
 
It's crashing the moment the map loads. I think it might be an artdefines problem.


EDIT: I think I fixed it!

EDIT EDIT: Nope. It announces 'You are defeated!' at the start of the map. Is there any way to delay the code until turn 840AD?
 
Ah, okay, that's needed because you have to know, which variables are given.

EDIT EDIT: Nope. It announces 'You are defeated!' at the start of the map. Is there any way to delay the code until turn 840AD?

o_O.
Please enable the python exceptions in the BtS.ini.
 
Man, just read a tutorial on Python. :rolleyes: Any tutorial.

This is not programming, this is copy-pasting random stuff. You don't need help fixing the code - you need someone to make code for you. Hire a programmer?

edit: I don't mean to come off all hostile and non-helpful. But the fact remains - this is not the way to do it. I happen to find this type of threads very frustrating personally, so I should probably just ignore them... :rolleyes:
 
I agree. Nobody is forcing you to reply to threads you don't like.
Yeah, there is definitely a minimum requirement for replying to modders asking for help. They actually need to try. :rolleyes: Otherwise they are just wasting everyone's time, their own and mine included. Well, I'm not doing that anymore. Please correct me if you notice me falling into my old habits.
 
Top Bottom