• Civilization 7 has been announced. For more info please check the forum here .

HELP adding a python wonder to my mod!

And I looked in the debug files that you described, and here's what I found. First from PythonErr.log:

Code:
Traceback (most recent call last):
  File "BugConfig", line 110, in unknown_endtag
  File "BugConfig", line 334, in endChild
  File "BugConfig", line 337, in end
  File "BugConfig", line 318, in process
  File "BugConfig", line 547, in handle
  File "BugUtil", line 622, in callFunction
  File "BugUtil", line 599, in lookupFunction
  File "<string>", line 35, in load_module
  File "<string>", line 13, in _get_code
  File "DiplomacyEventManager", line 300
 
    if ( iXLoop != iXPeak or iYLoop != iYPeak ):
 
    ^
 
SyntaxError: invalid syntax

The Dbg file didn't seem to have anything pertaining to this in it. But to make it a bit easier on you, here is the python code from the section referred to in this, lines 289 through 303, with line 300 hilighted:

Code:
				### set additional bonus for peaks in the wonder city radius ###
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if(pPlot.getTerrainType() != -1):
									if ( pPlot.isPeak()==true  ):
										CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)

											### ausgabe ###
									[COLOR="Red"]		if ( iXLoop != iXPeak or iYLoop != iYPeak ):[/COLOR]
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_212.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
											else:
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_218.dds',ColorTypes(5), iXLoop, iYLoop,True,True)

EDIT: I bumped my last post, check the last page for the files (I think) you asked me to post.
 
If you look carefully, you can notice that the line that gives you syntax error is one tab further left than the line before. As EmperorFool said
As for indentation, Python is very picky that it match other lines indented to the same level in the same block, or that you indent after an if: or else:, etc. It doesn't care about how much you indent (one or two or 45 tabs), as long as it matches the other lines around it that are at the same level. That being said, I would highly recommend fixing it just the same. You can never be too careful where Python and indentation are concerned.
 
If you look carefully, you can notice that the line that gives you syntax error is one tab further left than the line before. As EmperorFool said

Further left or further right? The one I hilighted is line 300, which was the one referred to in the PythonErr file. So should it be like this...

Code:
				### set additional bonus for peaks in the wonder city radius ###
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if(pPlot.getTerrainType() != -1):
									if ( pPlot.isPeak()==true  ):
										CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)

										### ausgabe ###
									[COLOR="Red"]	if ( iXLoop != iXPeak or iYLoop != iYPeak ):
											CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_212.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
										else:
											CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_218.dds',ColorTypes(5), iXLoop, iYLoop,True,True)[/COLOR]

????
 
Cool, I'll try checking it out again! :goodjob:

Although if that was the only line that was wrong, wouldn't all of the other lines work? Shouldn't I still get the peak bonuses and have the improvement appear on the peak?
 
Cool, I'll try checking it out again! :goodjob:

Although if that was the only line that was wrong, wouldn't all of the other lines work? Shouldn't I still get the peak bonuses and have the improvement appear on the peak?

:dunno: I don't know enough python to answer that, but I think we'll know more after you test that code.
 
Alright that seems to have worked, although it gives the bonus to every peak tile and I only wanted it in the city that built the wonder, but I suppose it isn't too bad like this (there usually aren't many peaks anyway). I'll run it by the rest of the people helping me with my mod and see what they think.

But thanks a lot you guys! :goodjob:

I told you I'd be back. Hopefully this is going to be the last time I bug you, but that is doubtful. I know how difficult it is to explain something like this to somebody, especially when they clearly have no idea what they are doing, so I really appreciate the help you have given me, and if you need anything done graphically don't hesitate to ask me.

EDIT: From what I can tell, when you build the wonder it pop's up those little circular event notification things (you know what I mean, like if it says "enemy spotted near Berlin" and shows the unit's button in the red circle, it does that I think) on all the peaks in your Empire, which I guess informs you that they are now workable. That's probably what that last bit of code does.
 
Oh, I should also mention that I am still getting that NO_IMPROVEMENT assert failure. The NO_IMPROVEMENT tag is not referenced anywhere in my python, the only place it is referenced in the entire mod in fact is in the CIV4PlotLSystem.xml. The only thing I can think of is, that since this deals with bonuses and improvements, that maybe a bonus is referenced that it can't find or something like that? I have no idea why this assert failure keeps coming up, but from what I can tell it doesn't seem to effect anything.

Any ideas?
 
Python modules are what all those .py files are called in the Python documentation. That file looks fine at first glance, so I really need to see the PythonErr.log and PythonDbg.log files.
 
Bah, too many threads to follow and I forget to check the next page before replying. So you have it working but you don't want those messages for every peak, right? That shouldn't be too hard.

The message on every peak empire-wide is this line:

Code:
CyInterface().addMessage(iPID,True,0,' ','',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_211.dds',ColorTypes(5), iXLoop, iYLoop,True,True)

and the message for the peaks in the city is this:

Code:
if ( iXLoop != iXPeak or iYLoop != iYPeak ):
	CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_212.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
else:
	CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_218.dds',ColorTypes(5), iXLoop, iYLoop,True,True)

You will see a little circular flag if you specify the X and Y coordinates for it. Set both to -1 to skip the flag. But the call to addMessage() will produce a message in the event log regardless, so you may want to remove the entire call in some cases. I would recommend having just one message for where the wonder gets placed, and maybe not even then since the city will have a flag itself.

You can safely remove both blocks posted above.

This is the message for the peak where the wonder gets placed (between the two above):

Code:
CyInterface().addMessage(iPID,false,10,CyTranslator().getText("TXT_KEY_MACHU_PICCHU_GAMETXT1",(iXPeak,iXPeak)),'',0,gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_MACHU_PICCHU")).getButton(),ColorTypes(5), iXPeak, iYPeak,True,True)

You could also remove that line.
 
Alright, thanks. Were you able to figure out why I'm getting that NO_IMPROVEMENT assert failure? It started when I put Machu Picchu in so it must be related.
 
It comes up with a new game is initializing/loading up whatever you want to call it. So if I start a new game it occurs when that game is being set up. It pops up with around four to five windows all saying the same thing.
 
Post the XML for the building and building class--just the additional stuff not the entire XML files.
 
Code:
		<BuildingClassInfo>
			<Type>BUILDINGCLASS_MACHU_PICCHU</Type>
			<Description>TXT_KEY_BUILDING_MACHU_PICCHU</Description>
			<iMaxGlobalInstances>1</iMaxGlobalInstances>
			<iMaxTeamInstances>-1</iMaxTeamInstances>
			<iMaxPlayerInstances>-1</iMaxPlayerInstances>
			<iExtraPlayerInstances>0</iExtraPlayerInstances>
			<bNoLimit>0</bNoLimit>
			<bMonument>1</bMonument>
			<DefaultBuilding>BUILDING_MACHU_PICCHU</DefaultBuilding>
			<VictoryThresholds/>
		</BuildingClassInfo>

Code:
		<BuildingInfo>
			<BuildingClass>BUILDINGCLASS_MACHU_PICCHU</BuildingClass>
			<Type>BUILDING_MACHU_PICCHU</Type>
			<SpecialBuildingType>NONE</SpecialBuildingType>
			<Description>TXT_KEY_BUILDING_MACHU_PICCHU</Description>
			<Civilopedia>TXT_KEY_BUILDING_MACHU_PICCHU_PEDIA</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_MACHU_PICCHU_STRATEGY</Strategy>
			<Advisor>ADVISOR_ECONOMY</Advisor>
			<ArtDefineTag>ART_DEF_BUILDING_MACHU_PICCHU</ArtDefineTag>
			<MovieDefineTag>ART_DEF_MOVIE_MACHU_PICCHU</MovieDefineTag>
			<HolyCity>NONE</HolyCity>
			<ReligionType>NONE</ReligionType>
			<StateReligion>NONE</StateReligion>
			<bStateReligion>0</bStateReligion>
			<PrereqReligion>NONE</PrereqReligion>
			<PrereqCorporation>NONE</PrereqCorporation>
			<FoundsCorporation>NONE</FoundsCorporation>
			<GlobalReligionCommerce>NONE</GlobalReligionCommerce>
			<GlobalCorporationCommerce>NONE</GlobalCorporationCommerce>
			<VictoryPrereq>NONE</VictoryPrereq>
			<FreeStartEra>NONE</FreeStartEra>
			<MaxStartEra>ERA_INDUSTRIAL</MaxStartEra>
			<ObsoleteTech>NONE</ObsoleteTech>
			<PrereqTech>TECH_CODE_OF_LAWS</PrereqTech>
			<TechTypes/>
			<Bonus>NONE</Bonus>
			<PrereqBonuses/>
			<ProductionTraits/>
			<HappinessTraits/>
			<NoBonus>NONE</NoBonus>
			<PowerBonus>NONE</PowerBonus>
			<FreeBonus>NONE</FreeBonus>
			<iNumFreeBonuses>0</iNumFreeBonuses>
			<FreeBuilding>NONE</FreeBuilding>
			<FreePromotion>NONE</FreePromotion>
			<CivicOption>NONE</CivicOption>
			<GreatPeopleUnitClass>UNITCLASS_ENGINEER</GreatPeopleUnitClass>
			<iGreatPeopleRateChange>1</iGreatPeopleRateChange>
			<iHurryAngerModifier>0</iHurryAngerModifier>
			<bBorderObstacle>0</bBorderObstacle>
			<bTeamShare>0</bTeamShare>
			<bWater>0</bWater>
			<bRiver>0</bRiver>
			<bPower>0</bPower>
			<bDirtyPower>0</bDirtyPower>
			<bAreaCleanPower>0</bAreaCleanPower>
			<DiploVoteType>NONE</DiploVoteType>
			<bForceTeamVoteEligible>0</bForceTeamVoteEligible>
			<bCapital>0</bCapital>
			<bGovernmentCenter>0</bGovernmentCenter>
			<bGoldenAge>0</bGoldenAge>
			<bAllowsNukes>0</bAllowsNukes>
			<bMapCentering>0</bMapCentering>
			<bNoUnhappiness>0</bNoUnhappiness>
			<bNoUnhealthyPopulation>0</bNoUnhealthyPopulation>
			<bBuildingOnlyHealthy>0</bBuildingOnlyHealthy>
			<bNeverCapture>0</bNeverCapture>
			<bNukeImmune>1</bNukeImmune>
			<bPrereqReligion>0</bPrereqReligion>
			<bCenterInCity>0</bCenterInCity>
			<iAIWeight>0</iAIWeight>
			<iCost>200</iCost>
			<iHurryCostModifier>100</iHurryCostModifier>
			<iAdvancedStartCost>-1</iAdvancedStartCost>
			<iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
			<iMinAreaSize>-1</iMinAreaSize>
			<iConquestProb>100</iConquestProb>
			<iCitiesPrereq>0</iCitiesPrereq>
			<iTeamsPrereq>0</iTeamsPrereq>
			<iLevelPrereq>0</iLevelPrereq>
			<iMinLatitude>0</iMinLatitude>
			<iMaxLatitude>90</iMaxLatitude>
			<iGreatPeopleRateModifier>0</iGreatPeopleRateModifier>
			<iGreatGeneralRateModifier>0</iGreatGeneralRateModifier>
			<iDomesticGreatGeneralRateModifier>0</iDomesticGreatGeneralRateModifier>
			<iGlobalGreatPeopleRateModifier>0</iGlobalGreatPeopleRateModifier>
			<iAnarchyModifier>0</iAnarchyModifier>
			<iGoldenAgeModifier>0</iGoldenAgeModifier>
			<iGlobalHurryModifier>0</iGlobalHurryModifier>
			<iExperience>0</iExperience>
			<iGlobalExperience>0</iGlobalExperience>
			<iFoodKept>0</iFoodKept>
			<iAirlift>0</iAirlift>
			<iAirModifier>0</iAirModifier>
			<iAirUnitCapacity>0</iAirUnitCapacity>
			<iNukeModifier>0</iNukeModifier>
			<iNukeExplosionRand>0</iNukeExplosionRand>
			<iFreeSpecialist>0</iFreeSpecialist>
			<iAreaFreeSpecialist>0</iAreaFreeSpecialist>
			<iGlobalFreeSpecialist>0</iGlobalFreeSpecialist>
			<iMaintenanceModifier>0</iMaintenanceModifier>
			<iWarWearinessModifier>0</iWarWearinessModifier>
			<iGlobalWarWearinessModifier>0</iGlobalWarWearinessModifier>
			<iEnemyWarWearinessModifier>0</iEnemyWarWearinessModifier>
			<iHealRateChange>0</iHealRateChange>
			<iHealth>0</iHealth>
			<iAreaHealth>0</iAreaHealth>
			<iGlobalHealth>0</iGlobalHealth>
			<iHappiness>0</iHappiness>
			<iAreaHappiness>0</iAreaHappiness>
			<iGlobalHappiness>0</iGlobalHappiness>
			<iStateReligionHappiness>0</iStateReligionHappiness>
			<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
			<iMilitaryProductionModifier>0</iMilitaryProductionModifier>
			<iSpaceProductionModifier>0</iSpaceProductionModifier>
			<iGlobalSpaceProductionModifier>0</iGlobalSpaceProductionModifier>
			<iTradeRoutes>0</iTradeRoutes>
			<iCoastalTradeRoutes>0</iCoastalTradeRoutes>
			<iGlobalTradeRoutes>0</iGlobalTradeRoutes>
			<iTradeRouteModifier>0</iTradeRouteModifier>
			<iForeignTradeRouteModifier>0</iForeignTradeRouteModifier>
			<iGlobalPopulationChange>0</iGlobalPopulationChange>
			<iFreeTechs>0</iFreeTechs>
			<iDefense>0</iDefense>
			<iBombardDefense>0</iBombardDefense>
			<iAllCityDefense>0</iAllCityDefense>
			<iEspionageDefense>0</iEspionageDefense>
			<iAsset>10</iAsset>
			<iPower>0</iPower>
			<fVisibilityPriority>0.0</fVisibilityPriority>
			<SeaPlotYieldChanges/>
			<RiverPlotYieldChanges/>
			<GlobalSeaPlotYieldChanges/>
			<YieldChanges>
				<iYield>0</iYield>
				<iYield>0</iYield>
				<iYield>2</iYield>
			</YieldChanges>
			<CommerceChanges/>
			<ObsoleteSafeCommerceChanges>
				<iCommerce>0</iCommerce>
				<iCommerce>0</iCommerce>
				<iCommerce>4</iCommerce>
			</ObsoleteSafeCommerceChanges>
			<CommerceChangeDoubleTimes>
				<iCommerce>0</iCommerce>
				<iCommerce>0</iCommerce>
				<iCommerce>1000</iCommerce>
			</CommerceChangeDoubleTimes>
			<CommerceModifiers/>
			<GlobalCommerceModifiers/>
			<SpecialistExtraCommerces/>
			<StateReligionCommerces/>
			<CommerceHappinesses/>
			<ReligionChanges/>
			<SpecialistCounts/>
			<FreeSpecialistCounts/>
			<CommerceFlexibles/>
			<CommerceChangeOriginalOwners>
				<bCommerceChangeOriginalOwner>0</bCommerceChangeOriginalOwner>
				<bCommerceChangeOriginalOwner>0</bCommerceChangeOriginalOwner>
				<bCommerceChangeOriginalOwner>1</bCommerceChangeOriginalOwner>
			</CommerceChangeOriginalOwners>
			<ConstructSound>AS2D_BUILD_CASTLE</ConstructSound>
			<BonusHealthChanges>
				<BonusHealthChange>
					<BonusType>BONUS_STONE</BonusType>
					<iHealthChange>2</iHealthChange>
				</BonusHealthChange>
			</BonusHealthChanges>
			<BonusHappinessChanges>
				<BonusHappinessChange>
					<BonusType>BONUS_STONE</BonusType>
					<iHappinessChange>2</iHappinessChange>
				</BonusHappinessChange>
			</BonusHappinessChanges>
			<BonusProductionModifiers>
				<BonusProductionModifier>
					<BonusType>BONUS_STONE</BonusType>
					<iProductonModifier>100</iProductonModifier>
				</BonusProductionModifier>
			</BonusProductionModifiers>
			<UnitCombatFreeExperiences/>
			<DomainFreeExperiences/>
			<DomainProductionModifiers/>
			<BuildingHappinessChanges/>
			<PrereqBuildingClasses/>
			<BuildingClassNeededs/>
			<SpecialistYieldChanges/>
			<BonusYieldModifiers/>
			<ImprovementFreeSpecialists/>
			<Flavors>
				<Flavor>
					<FlavorType>FLAVOR_GOLD</FlavorType>
					<iFlavor>10</iFlavor>
				</Flavor>
			</Flavors>
			<HotKey/>
			<bAltDown>0</bAltDown>
			<bShiftDown>0</bShiftDown>
			<bCtrlDown>0</bCtrlDown>
			<iHotKeyPriority>0</iHotKeyPriority>
		</BuildingInfo>
 
Welp, I don't see NO_IMPROVEMENT in there, so I dunno what's up. Are you sure this error appeared once you added only this building? Try adding just the above XML to a new empty mod folder and see what happens.

BTW, +2:hammers: for the building and +2:)/+2:health: for Stone on top of turning every Peak into a +1:commerce: Plains Forest? :wow:
 
Welp, I don't see NO_IMPROVEMENT in there, so I dunno what's up. Are you sure this error appeared once you added only this building? Try adding just the above XML to a new empty mod folder and see what happens.

BTW, +2:hammers: for the building and +2:)/+2:health: for Stone on top of turning every Peak into a +1:commerce: Plains Forest? :wow:

Couldn't I just search for NO_IMPROVEMENT in all of my XML files?

And yeah, I know the stats on the wonder are pretty ridiculously high, but I haven't edited them yet. Those were GIR's original effects, I am definitely going to tone it down.
 
This may or may not help. The only XML file I have in my mod that references NO_IMPROVEMENT at all is the CIV4PlotLSystem.xml file. I have attached it. The NO_IMPROVEMENT tag appears on lines 7571, 7662, 7730, 7802, 7858, 7913... and so on, I'm sure you have a search function. Here's just an example of one of them...

Code:
		<ArtRef Name="art:Tobacco_crop">
			<!-- when in the rough ... there's anotehr in 3x2 for farms -->
			<Attribute Class="Scalar">NIF:Art/Terrain/Resources/Tobacco/Tobacco.nif::2x2_01_Tobacco_Normal</Attribute>
			<Attribute Class="Improvement">[COLOR="Red"]NO_IMPROVEMENT[/COLOR],IMPROVEMENT_LAND_WORKED,IMPROVEMENT_FARM</Attribute>
			<Attribute Class="Bonus">BONUS_TOBACCO</Attribute>
			<Attribute Class="Scalar">bCutTrees:1</Attribute>
			<Attribute Class="Scalar">bBonusImprovedOnly:0</Attribute>
			<Attribute Class="Scalar">bIsPartOfBonus:1</Attribute>
			<Attribute Class="Scalar">szBatchGroup:tobacco_crop</Attribute>
			<Scale>0.8</Scale>
			<Rotate>+45</Rotate>
		</ArtRef>

You know what though, I don't have a TOBACCO resource in my mod. So what the hell is this doing here?
 

Attachments

  • CIV4PlotLSystem.rar
    19.1 KB · Views: 42
You could try replacing all of those with NONE to see if it fixes the assertion error, but do some thorough testing to make sure that works. Or you could just remove that resource that you aren't using.
 
Top Bottom