• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Modmodding Q&A Thread

Where do I add message notification in-game?

I am thinking maybe I could use some for the CNM.. "After the great fire tragedy of al-Fustat, a new city has been founded in the area and shall be known as al-Qahira" that appears at some fixed game turns just like the "Seljuk Hordes has invaded ..."
 
You're probably looking for the CyInterface().addMessage() method. It takes a bunch of arguments that I can never remember, I suggest you search for it in the Python folder and just make the copy suit your needs.
 
In barbs.py, lin 489.

Code:
	def checkSpawn(self, iPlayer, iUnitType, iNumUnits, tTL, tBR, spawnFunction, iTurn, iPeriod, iRest, lAdj=[]):

What do iPeriod and iRest exactly do?
 
The units will spawn in every iTurn where iTurn module iPeriod equals iRest.

In other words, spawns will happen every iPeriod turns with an offset of iRest turns. This is to prevent that all spawns with the same interval or intervals that are fractions of others don't happen in the same turn.
 
Do you know how to add new categories to the sevopedia? I just can't work it out [pissed].


Spoiler :

def placeBuilding(self):
screen = self.top.getScreen()
panelName = self.top.getNextWidgetName()
screen.addPanel(panelName, localText.getText("TXT_KEY_UNIQUE_BUILDINGS", ()), "", False, True, self.X_BUILDING, self.Y_BUILDING, self.W_BUILDING, self.H_BUILDING, PanelStyles.PANEL_STYLE_BLUE50)
screen.attachLabel(panelName, "", " ")
for iBuilding in range(gc.getNumBuildingClassInfos()):
iUniqueBuilding = gc.getCivilizationInfo(self.iCivilization).getCivilizationBuildings(iBuilding)
iDefaultBuilding = gc.getBuildingClassInfo(iBuilding).getDefaultBuildingIndex()
if (iDefaultBuilding > -1 and iUniqueBuilding > -1 and iDefaultBuilding != iUniqueBuilding):
screen.attachImageButton(panelName, "", gc.getBuildingInfo(iUniqueBuilding).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, iUniqueBuilding, 1, False)

if self.iCivilization == con.iAmerica:
screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iAmeEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iAmeEmbassy, 1, False)

if self.iCivilization == con.iArabia:
screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iAraEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iAraEmbassy, 1, False)

All of it works without python errors and correctly arranges itself except that the Embassies don't appear in the unique building section of the civilization? (it has the correct indent arrangement)


Do you know how to tell the unit finder to ignore the slave unique units?
 
Not sure what you're trying to do there, using the [code][/code] environment might help making it more readable.

And what unit finder are you talking about?
 
If you want to add a new category, you have to edit the DLL to get a new WIDGET_PEDIA_JUMP_TO_XXX widget. Otherwise, you can't open that page.

(This isn't necessary for all things. Wonders use the JUMP_TO_BUILDING widget, even though it's a separate page)
 
Not sure what you're trying to do there, using the [code][/code] environment might help making it more readable.

And what unit finder are you talking about?

Sorry for being unclear. I've made the civilization screen look like this.
2014-11-25_00001.jpg
It all works fine with no python errors. Now, I want to add the civilizations embassy to the unique building section. I'm using the code you used to add the apostolic palace to the orthodox founding requirements. It works when I've used it for civics, religions, buildings and technologies but it doesn't add the embassy and doesn't show any python exceptions.
Code:
def placeBuilding(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel(panelName, localText.getText("TXT_KEY_UNIQUE_BUILDINGS", ()), "", False, True, self.X_BUILDING, self.Y_BUILDING, self.W_BUILDING, self.H_BUILDING, PanelStyles.PANEL_STYLE_BLUE50)
		screen.attachLabel(panelName, "", "  ")
		for iBuilding in range(gc.getNumBuildingClassInfos()):
			iUniqueBuilding = gc.getCivilizationInfo(self.iCivilization).getCivilizationBuildings(iBuilding)
			iDefaultBuilding = gc.getBuildingClassInfo(iBuilding).getDefaultBuildingIndex()
			if (iDefaultBuilding > -1 and iUniqueBuilding > -1 and iDefaultBuilding != iUniqueBuilding):
				screen.attachImageButton(panelName, "", gc.getBuildingInfo(iUniqueBuilding).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, iUniqueBuilding, 1, False)

		if self.iCivilization == con.iAmerica:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iAmeEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iAmeEmbassy, 1, False)

		if self.iCivilization == con.iArabia:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iAraEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iAraEmbassy, 1, False)

The question about the units was because the unique units code includes the slave unique units. They show up in the unique units category and I was wondering if you knew how to remove them.

If you want to add a new category, you have to edit the DLL to get a new WIDGET_PEDIA_JUMP_TO_XXX widget. Otherwise, you can't open that page.

(This isn't necessary for all things. Wonders use the JUMP_TO_BUILDING widget, even though it's a separate page)

Thanks.
 
Sorry for being unclear. I've made the civilization screen look like this.
View attachment 386332
It all works fine with no python errors. Now, I want to add the civilizations embassy to the unique building section. I'm using the code you used to add the apostolic palace to the orthodox founding requirements. It works when I've used it for civics, religions, buildings and technologies but it doesn't add the embassy and doesn't show any python exceptions.
Code:
def placeBuilding(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel(panelName, localText.getText("TXT_KEY_UNIQUE_BUILDINGS", ()), "", False, True, self.X_BUILDING, self.Y_BUILDING, self.W_BUILDING, self.H_BUILDING, PanelStyles.PANEL_STYLE_BLUE50)
		screen.attachLabel(panelName, "", "  ")
		for iBuilding in range(gc.getNumBuildingClassInfos()):
			iUniqueBuilding = gc.getCivilizationInfo(self.iCivilization).getCivilizationBuildings(iBuilding)
			iDefaultBuilding = gc.getBuildingClassInfo(iBuilding).getDefaultBuildingIndex()
			if (iDefaultBuilding > -1 and iUniqueBuilding > -1 and iDefaultBuilding != iUniqueBuilding):
				screen.attachImageButton(panelName, "", gc.getBuildingInfo(iUniqueBuilding).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, iUniqueBuilding, 1, False)

		if self.iCivilization == con.iAmerica:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iAmeEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iAmeEmbassy, 1, False)

		if self.iCivilization == con.iArabia:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iAraEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iAraEmbassy, 1, False)
Oh, now I get it, thanks for the explanation. I was mostly confused by the explicit treatment of America and Arabia, but I guess this is just for testing purposes.

Your problem is that you are dealing with civilizations, while the iAmerica, iArabia ... constants refer to player slots. The appropriate civ constants are called iCivAmerica, iCivArabia ...

Unfortunately the order of the embassies is determined by player slot IDs, so there is no easy way to match embassy IDs and civilization IDs.

The question about the units was because the unique units code includes the slave unique units. They show up in the unique units category and I was wondering if you knew how to remove them.
They should be declared as bGraphicalOnly, which you can check for with gc.getUnitInfo([unit id]).isGraphicalOnly(). By the way, you can exclude the "unique" GPs in the same way, which are only in there for dynamic names and are not different from normal GPs.
 
Code:
	def placeBuilding(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel(panelName, localText.getText("TXT_KEY_UNIQUE_BUILDINGS", ()), "", False, True, self.X_BUILDING, self.Y_BUILDING, self.W_BUILDING, self.H_BUILDING, PanelStyles.PANEL_STYLE_BLUE50)
		screen.attachLabel(panelName, "", "  ")
		for iBuilding in range(gc.getNumBuildingClassInfos()):
			iUniqueBuilding = gc.getCivilizationInfo(self.iCivilization).getCivilizationBuildings(iBuilding)
			iDefaultBuilding = gc.getBuildingClassInfo(iBuilding).getDefaultBuildingIndex()
			if (iDefaultBuilding > -1 and iUniqueBuilding > -1 and iDefaultBuilding != iUniqueBuilding[B] and iUniqueBuilding != gc.getBuildingInfo[con.iIberianTradingCompany][/B]):
				screen.attachImageButton(panelName, "", gc.getBuildingInfo(iUniqueBuilding).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, iUniqueBuilding, 1, False)
The python exception just says "TypeError: unscriptable object". When I remove the "and iUniqueBuilding != gc.getBuildingInfo[con.iIberianTradingCompany]" it works fine. I assume I'm just doing it wrong since I'm learning python. :)

I would have tried "gc.getUnitInfo([unit id]).isGraphicalOnly()" but I didn't know where to place it.

Thanks for your help.

Edit: I forgot to mention that I want to keep the Great People in the unique units section.
 
I would have tried "gc.getUnitInfo([unit id]).isGraphicalOnly()" but I didn't know where to place it.

Thanks for your help.

I would place it directly after the for loop.

Code:
	def placeUnit(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel(panelName, localText.getText("TXT_KEY_FREE_UNITS", ()), "", False, True, self.X_UNIT, self.Y_UNIT, self.W_UNIT, self.H_UNIT, PanelStyles.PANEL_STYLE_BLUE50)
		screen.attachLabel(panelName, "", "  ")
		for iUnit in range(gc.getNumUnitClassInfos()):
[COLOR="Blue"]			if gc.getUnitInfo(iUnit).isGraphicalOnly(): continue[/COLOR]
			iUniqueUnit = gc.getCivilizationInfo(self.iCivilization).getCivilizationUnits(iUnit)
			iDefaultUnit = gc.getUnitClassInfo(iUnit).getDefaultUnitIndex()
			if (iDefaultUnit > -1 and iUniqueUnit > -1 and iDefaultUnit != iUniqueUnit):
				screen.attachImageButton(panelName, "", gc.getUnitInfo(iUniqueUnit).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_UNIT, iUniqueUnit, 1, False)
 
Code:
	def placeBuilding(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel(panelName, localText.getText("TXT_KEY_UNIQUE_BUILDINGS", ()), "", False, True, self.X_BUILDING, self.Y_BUILDING, self.W_BUILDING, self.H_BUILDING, PanelStyles.PANEL_STYLE_BLUE50)
		screen.attachLabel(panelName, "", "  ")
		for iBuilding in range(gc.getNumBuildingClassInfos()):
			iUniqueBuilding = gc.getCivilizationInfo(self.iCivilization).getCivilizationBuildings(iBuilding)
			iDefaultBuilding = gc.getBuildingClassInfo(iBuilding).getDefaultBuildingIndex()
			if (iDefaultBuilding > -1 and iUniqueBuilding > -1 and iDefaultBuilding != iUniqueBuilding[B] and iUniqueBuilding != gc.getBuildingInfo[con.iIberianTradingCompany][/B]):
				screen.attachImageButton(panelName, "", gc.getBuildingInfo(iUniqueBuilding).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, iUniqueBuilding, 1, False)
The python exception just says "TypeError: unscriptable object". When I remove the "and iUniqueBuilding != gc.getBuildingInfo[con.iIberianTradingCompany]" it works fine. I assume I'm just doing it wrong since I'm learning python. :)
Yes, that's a syntax error.

The message was likely "unsubscriptable object". You were using the [] operator on getBuildingInfo, which is a method of the CyGlobalContext object gc. [] is only used to access entries of lists, tuples or dictionaries (i.e. specific types of variables) and can never be used on methods. You can only call methods with the () operator.

Furthermore, gc.getBuildingInfo(int ID) returns an object of type CyBuildingInfo, while iUniqueBuilding is just an integer, and comparing them either would create another error or always be false (not sure how Python handles this honestly). Simply comparing iUniqueBuilding != con.iIberianTradingCompany would be enough. An equivalent, but needlessly complicated statement is iUniqueBuilding != gc.getBuildingInfo(con.iIberianTradingCompany).getBuildingType().

The Iberian Trading Company building is also marked as bGraphicalOnly by the way, so you can exclude it in a similar way by checking gc.getBuilding(iUniqueBuilding).isGraphicalOnly().
 
Yes, that's a syntax error.

The message was likely "unsubscriptable object". You were using the [] operator on getBuildingInfo, which is a method of the CyGlobalContext object gc. [] is only used to access entries of lists, tuples or dictionaries (i.e. specific types of variables) and can never be used on methods. You can only call methods with the () operator.

Furthermore, gc.getBuildingInfo(int ID) returns an object of type CyBuildingInfo, while iUniqueBuilding is just an integer, and comparing them either would create another error or always be false (not sure how Python handles this honestly). Simply comparing iUniqueBuilding != con.iIberianTradingCompany would be enough. An equivalent, but needlessly complicated statement is iUniqueBuilding != gc.getBuildingInfo(con.iIberianTradingCompany).getBuildingType().

The Iberian Trading Company building is also marked as bGraphicalOnly by the way, so you can exclude it in a similar way by checking gc.getBuilding(iUniqueBuilding).isGraphicalOnly().

Thanks that's all I need for now. :bowdown: Also buildings cannot be set to bGraphicalOnly in the xml it creates an error. (iberiantradingcompany isn't set to bGraphicalOnly)
 
You're right, must have misremembered.
 
2014-11-26_00002.jpg2014-11-26_00003.jpg
Spoiler :
Code:
	def placeBuilding(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel(panelName, localText.getText("TXT_KEY_UNIQUE_BUILDINGS", ()), "", False, True, self.X_BUILDING, self.Y_BUILDING, self.W_BUILDING, self.H_BUILDING, PanelStyles.PANEL_STYLE_BLUE50)
		screen.attachLabel(panelName, "", "  ")
		for iBuilding in range(gc.getNumBuildingClassInfos()):
			iUniqueBuilding = gc.getCivilizationInfo(self.iCivilization).getCivilizationBuildings(iBuilding)
			iDefaultBuilding = gc.getBuildingClassInfo(iBuilding).getDefaultBuildingIndex()
			if (iDefaultBuilding > -1 and iUniqueBuilding > -1 and iDefaultBuilding != iUniqueBuilding and iUniqueBuilding != con.iIberianTradingCompany):
				screen.attachImageButton(panelName, "", gc.getBuildingInfo(iUniqueBuilding).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, iUniqueBuilding, 1, False)

		if self.iCivilization == con.iCivAmerica:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iAmeEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iAmeEmbassy, 1, False)

		if self.iCivilization == con.iCivArabia:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iAraEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iAraEmbassy, 1, False)

[B]		if self.iCivilization == con.iCivArgentina:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iArgEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iArgEmbassy, 1, False)

		if self.iCivilization == con.iCivAztec:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iAztEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iAztEmbassy, 1, False)
[/B]
		if self.iCivilization == con.iCivBabylonia:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iBabEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iBabEmbassy, 1, False)

		if self.iCivilization == con.iCivBrazil:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iBraEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iBraEmbassy, 1, False)

		if self.iCivilization == con.iCivByzantium:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iByzEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iByzEmbassy, 1, False)

		if self.iCivilization == con.iCivCanada:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iCanEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iCanEmbassy, 1, False)

		if self.iCivilization == con.iCivCarthage:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iCarEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iCarEmbassy, 1, False)

		if self.iCivilization == con.iCivChina:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iChiEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iChiEmbassy, 1, False)

		if self.iCivilization == con.iCivColombia:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iMayEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iMayEmbassy, 1, False)

		if self.iCivilization == con.iCivEgypt:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iEgyEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iEgyEmbassy, 1, False)

		if self.iCivilization == con.iCivEngland:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iEngEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iEngEmbassy, 1, False)

		if self.iCivilization == con.iCivEthiopia:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iEthEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iEthEmbassy, 1, False)

		if self.iCivilization == con.iCivFrance:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iFraEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iFraEmbassy, 1, False)

		if self.iCivilization == con.iCivGermany:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iGerEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iGerEmbassy, 1, False)

		if self.iCivilization == con.iCivGreece:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iGreEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iGreEmbassy, 1, False)

		if self.iCivilization == con.iCivHolyRoman:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.HreEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.HreEmbassy, 1, False)

		if self.iCivilization == con.iCivInca:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iIncEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iIncEmbassy, 1, False)

		if self.iCivilization == con.iCivIndia:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iIndEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iIndEmbassy, 1, False)

		if self.iCivilization == con.iCivIndonesia:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iInoEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iInoEmbassy, 1, False)

		if self.iCivilization == con.iCivIran:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iPerEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iPerEmbassy, 1, False)

		if self.iCivilization == con.iCivItaly:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iItaEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iItaEmbassy, 1, False)

		if self.iCivilization == con.iCivJapan:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iJapEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iJapEmbassy, 1, False)

		if self.iCivilization == con.iCivKhmer:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iKhmEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iKhmEmbassy, 1, False)

		if self.iCivilization == con.iCivKongo:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iConEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iConEmbassy, 1, False)

		if self.iCivilization == con.iCivKorea:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iKorEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iKorEmbassy, 1, False)

		if self.iCivilization == con.iCivMali:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iMalEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iMalEmbassy, 1, False)

		if self.iCivilization == con.iCivMaya:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iMayEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iMayEmbassy, 1, False)

		if self.iCivilization == con.iCivMexico:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iAztEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iAztEmbassy, 1, False)

		if self.iCivilization == con.iCivMongol:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iMonEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iMonEmbassy, 1, False)

		if self.iCivilization == con.iCivMoors:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iMooEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iMooEmbassy, 1, False)

		if self.iCivilization == con.iCivMughals:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iMugEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iMugEmbassy, 1, False)

		if self.iCivilization == con.iCivNetherlands:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iHolEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iHolEmbassy, 1, False)

		if self.iCivilization == con.iCivOttomans:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iTurEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iTurEmbassy, 1, False)

		if self.iCivilization == con.iCivPersia:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iPerEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iPerEmbassy, 1, False)

		if self.iCivilization == con.iCivPoland:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iPolEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iPolEmbassy, 1, False)

		if self.iCivilization == con.iCivPortugal:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iPorEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iPorEmbassy, 1, False)
			
		if self.iCivilization == con.iCivPolynesia:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iPlyEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iPlyEmbassy, 1, False)

		if self.iCivilization == con.iCivRome:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iRomEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iRomEmbassy, 1, False)

		if self.iCivilization == con.iCivRussia:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iRusEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iRusEmbassy, 1, False)

		if self.iCivilization == con.iCivSpain:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iSpaEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iSpaEmbassy, 1, False)

		if self.iCivilization == con.iCivTamils:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iTamEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iTamEmbassy, 1, False)

		if self.iCivilization == con.iCivThailand:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iThaEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iThaEmbassy, 1, False)

		if self.iCivilization == con.iCivTibet:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iTibEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iTibEmbassy, 1, False)

		if self.iCivilization == con.iCivViking:
			screen.attachImageButton(panelName, "", gc.getBuildingInfo(con.iVikEmbassy).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, con.iVikEmbassy, 1, False)
For some strange reason the Argentinian Civilization shows the Aztec Embassy and Vice Versa. :confused: I have tried entering the code several times but no success.

2014-11-26_00001.jpg
Code:
	def placeRequires(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel( panelName, localText.getText("TXT_KEY_PEDIA_PROVIDES", ()), "", False, True, self.X_BUILDING, self.Y_BUILDING, self.W_BUILDING, self.H_BUILDING, PanelStyles.PANEL_STYLE_BLUE50 )
		screen.attachLabel(panelName, "", "  ")


	def placeBuilding(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel( panelName, localText.getText("TXT_KEY_PEDIA_BOOSTS", ()), "", False, True, self.X_UNIT, self.Y_UNIT, self.W_UNIT, self.H_UNIT, PanelStyles.PANEL_STYLE_BLUE50 )
		screen.attachLabel(panelName, "", "  ")
The first panel shows the TXT_KEY but the second doesn't and they use the same code. :confused:
 
For the civ/embassy thing, I might have made a mistake in the constants and mixed up Argentina and Aztecs. The order in Consts.py has to match the order in CIV4CivilizationInfos.xml, but I will check later myself.

You also could have saved a lot of duplicate code by first declaring the civ/embassy relationships in a dictionary, like this:

Code:
dEmbassies = {
con.iCivAmerica : con.iAmeEmbassy,
con.iCivArabia : con.iAraEmbassy,
con.iCivArgentina : con.iArgEmbassy,
[...]
}

Then the button placement would have been simplified to:

Code:
if self.iCivilization in dEmbassies:
        screen.attachImageButton(panelName, "", gc.getBuildingInfo(dEmbassies[self.iCivilization]).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, dEmbassies[self.iCivilization], 1, False)

Covering all possible cases. But now that you've already made the effort it probably doesn't matter anymore.

Not sure about the panel thing, I know nothing about how the placeBuilding method works.
 
CvCity::canConstruct(BuildingTypes eBuilding) would be my guess, but I can't say for sure.
 
If I change this:
Spoiler :
Code:
		<BuildingArtInfo>
			<Type>ART_DEF_BUILDING_IND_EMBASSY</Type>
			<LSystem>LSYSTEM_1x1</LSystem>
			<bAnimated>0</bAnimated>
			<fScale>0.6</fScale>
			<fInterfaceScale>1.2</fInterfaceScale>
			<NIF>Art/Structures/Buildings/WWBank/WWBank.nif</NIF>
			<KFM/>
			<Button>[B],Art/Interface/Buttons/Civilizations/India.dds,Art/Interface/Buttons/Civics_Civilizations_Religions_Atlas.dds,2,6</Button>[/B]
		</BuildingArtInfo>
		<BuildingArtInfo>
			<Type>ART_DEF_BUILDING_CHI_EMBASSY</Type>
			<LSystem>LSYSTEM_1x1</LSystem>
			<bAnimated>0</bAnimated>
			<fScale>0.6</fScale>
			<fInterfaceScale>1.2</fInterfaceScale>
			<NIF>Art/Structures/Buildings/WWBank/WWBank.nif</NIF>
			<KFM/>
			<Button>[B],Art/Interface/Buttons/Civilizations/China.dds,Art/Interface/Buttons/Civics_Civilizations_Religions_Atlas.dds,5,5</Button>[/B]
		</BuildingArtInfo>
		<BuildingArtInfo>
			<Type>ART_DEF_BUILDING_KOR_EMBASSY</Type>
			<LSystem>LSYSTEM1x1</LSystem>
			<bAnimated>0</bAnimated>
			<fScale>0.6</fScale>
			<fInterfaceScale>1.2</fInterfaceScale>
			<NIF>Art/Structures/Buildings/WWBank/WWBank.nif</NIF>
			<KFM/>
			<Button>[B],Art/Interface/Buttons/Civilizations/Spain.dds,Art/Interface/Buttons/Warlords_Atlas_2.dds,4,1</Button>[/B]
		</BuildingArtInfo>
To this:
Spoiler :
Code:
		<BuildingArtInfo>
			<Type>ART_DEF_BUILDING_IND_EMBASSY</Type>
			<LSystem>LSYSTEM_1x1</LSystem>
			<bAnimated>0</bAnimated>
			<fScale>0.6</fScale>
			<fInterfaceScale>1.2</fInterfaceScale>
			<NIF>Art/Structures/Buildings/WWBank/WWBank.nif</NIF>
			<KFM/>
			<Button>[B],Art/Interface/Buttons/Civilizations/India.dds[/B]</Button>
		</BuildingArtInfo>
		<BuildingArtInfo>
			<Type>ART_DEF_BUILDING_CHI_EMBASSY</Type>
			<LSystem>LSYSTEM_1x1</LSystem>
			<bAnimated>0</bAnimated>
			<fScale>0.6</fScale>
			<fInterfaceScale>1.2</fInterfaceScale>
			<NIF>Art/Structures/Buildings/WWBank/WWBank.nif</NIF>
			<KFM/>
			<Button>[B],Art/Interface/Buttons/Civilizations/China.dds[/B]</Button>
		</BuildingArtInfo>
		<BuildingArtInfo>
			<Type>ART_DEF_BUILDING_KOR_EMBASSY</Type>
			<LSystem>LSYSTEM1x1</LSystem>
			<bAnimated>0</bAnimated>
			<fScale>0.6</fScale>
			<fInterfaceScale>1.2</fInterfaceScale>
			<NIF>Art/Structures/Buildings/WWBank/WWBank.nif</NIF>
			<KFM/>
			<Button>[B],Art/Interface/Buttons/Civilizations/Korea.dds[/B]</Button>
		</BuildingArtInfo>
The art works correctly in the city screen and civilopedia. But if you click the icon in the city screen so as to build it then the game crashes. :confused:



How would I get the return 1 to give all of the unique great people.
Code:
	def getUnitType(self, iUnit):
		if (isNationalWonderClass(gc.getBuildingInfo(iBuilding).getBuildingClassType())):
			return 1
		else:
			return 0
How would I change the code below to access the 1 instead of all units? I've tried "return self.pediaUnit.getUnitSortedList(1)" but it doesn't work because it need the units to be sorted in the sevopedia which they aren't.
Code:
	def getUnitGreatList(self):
		return self.getSortedList(gc.getNumUnitInfos(), gc.getUnitInfo)

I couldn't find the Secularism code so I'll just ask. Are there any other wonders that Secularism doesn't allow other than Apostolic Palace and all the Pantheon Wonders?
 
Back
Top Bottom