The Modding Q&A Thread

I've got some Python code preventing buildings from being built:
Code:
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		
		# player can't build an arcology if they have shielding or advanced shielding
		if eBuilding == gc.getInfoTypeForString("BUILDING_ARCOLOGY"):
			if pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
				return True

How can I prevent library from being built during Medieval Age or later if city owner has no Printing Press?

[EDIT]: Ok, I've got it:
Code:
		if eBuilding == gc.getInfoTypeForString("BUILDING_LIBRARY"):
			if ((gc.getPlayer(pCity.getOwner()).getCurrentEra() >= con.iMedieval) and not (gc.getTeam(gc.getPlayer(pCity.getOwner()).getTeam()).isHasTech(con.iPrintingPress))):
				return True
 
LuKo, it would go something like this:
Code:
        if ( eBuilding == gc.getInfoTypeForString("BUILDING_LIBRARY")
             and gc.getGame().getCurrentEra() >= gc.getInfoTypeForString("ERA_MEDIEVAL") ):
                return not gc.getTeam(gc.getPlayer(pCity.getOwner()).getTeam()).isHasTech(gc.getInfoTypeForString("TECH_PRINTING_PRESS")
You need to double-check all API methods and XML tags, since I never did. There could easily be a typo in there somewhere, but I'm sure you can manage it. ;)

edit: Note that there is difference between the game era and the player's current technological era. Use whatever makes most sense in this context.
 
I was actually unsure about Consts being available in the CvGameUtils module, but didn't bother to check. If its working, I guess it is. (Otherwise you may have just imported it yourself.)
 
Are there any kind of hidden modifiers that determine how much stability a civ must lose before collapsing? I got the feeling that civs like Turkey or Russia are a lot harder to collapse than China for example.
 
It works like this: At some interval of turns, a script looks up all players in turn, from Egypt all the way to America. The first one with less than -40 stability will collapse - the rest are saved, regardless of stability, this time around.

So you would be right; The earlier Civs are more likely to collapse than the later ones.
 
I thought a lot if it would be worthwhile to change that ... putting all civs in a list and sorting by stability should be easy.

On the other hand, maybe it's for the better that older civs die earlier.
 
I also modded this feature. Heavily. :D
 
I thought a lot if it would be worthwhile to change that ... putting all civs in a list and sorting by stability should be easy.

On the other hand, maybe it's for the better that older civs die earlier.

Not with your second rebirths as different civs. Italy is screwed then
 
Yeah, but it could be argued that this is also by design: That the "second coming" Civs should be more fickle.
 
Not five-hundred years after birth. And Leoreth already made newly reborn civs less stable than civs that spawn normally.
 
I also modded this feature. Heavily. :D
Cool, could you elaborate a little? The collapse system struck me as a little weird sometimes, with unstable civs surviving for too long etc.
 
Oh, I revamped all of the Rise'n'Fall features, including secessions and different types of AI collapses. The main idea was to keep some 20 odd players in-game at all times, so collapses will be more frequent the higher the number of active players. And the rebirth happens long before Nationalism, but becomes more commonplace the more players that gain the Tech. Again; The less active players, the more likely are the dead ones to re-surface. It, mostly, worked like a charm! :D

Stuff like that. But today I know a huge amount more programming than I did some 18 months ago, so I would probably end up revamping the entire mod if I ever revisited this. It would probably make more sense to make my own mod from the ground-up. If I only had the time. :lol:

Here's looking forward to retirement! :king:
 
I hope it's only temporary retirement :)
 
:lol: No, no... In the immediate future I will be (technically) home-less and (hopefully) working pretty much around-the-clock. So I'll only get back when I... land, somewhere and can pick up programming again.

With "retirement" I meant the far, distant future, when I ain't bothered with the daily grind no-more. Boat-drinks! :king:
 
How could I make it so congress was always on?
 
Always? Like from the first game turn?

You could do this on the command prompt of the built-in Python console. If you can manage to open it, that is. (Not everyone can.)

edit: In \Assets\Python\StoredData.py you change this line:
Code:
                                    'bCongressEnabled': False,
into:
Code:
                                    'bCongressEnabled': True,
 
Top Bottom