MrUnderhill
Civ-loving Hobbit
- Joined
- Dec 6, 2005
- Messages
- 655
I've finally gotten down to modding Civ4 in Python and I've already run into a bug. I've gotten it so that "and" prereqs get arrows drawn for them instead of "or" prereqs, but to make it more compatible with the existing tech tree (and other mods), I want to make it so that if a tech has only 1 "or" prereq, it gets treated like an "and" and gets an arrow drawn for it. But this doesn't work.
The above code crashes the event manager. When I change the "=" in "if (maxPrereqs = 1)" to a ">", it doesn't crash but still draws all prereqs as icons, rather than drawing them only if there are 2 or more.
I have tried to work my way around it several times, but none of them worked entirely, so I came here for help.
Code:
maxPrereqs=gc.getDefineINT("NUM_OR_TECH_PREREQS")
for j in range(maxPrereqs):
eTech = gc.getTechInfo(i).getPrereqOrTechs(j)
if ( eTech > -1 ):
if (maxPrereqs = 1):
fX = fX - X_INCREMENT
iX = 30 + ( (gc.getTechInfo(i).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
iY = ( gc.getTechInfo(i).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5
szTechPrereqID = "TechPrereqID" + str((i * 1000) + j)
screen.addDDSGFCAt( szTechPrereqID, "TechList", gc.getTechInfo(eTech).getButton(), iX + fX, iY + 6, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_TECH_PREPREQ, eTech, -1, False )
#szTechPrereqBorderID = "TechPrereqBorderID" + str((i * 1000) + j)
#screen.addDDSGFCAt( szTechPrereqBorderID, "TechList", ArtFileMgr.getInterfaceArtInfo("TECH_TREE_BUTTON_BORDER").getPath(), iX + fX + 4, iY + 22, 32, 32, WidgetTypes.WIDGET_HELP_TECH_PREPREQ, eTech, -1, False )
j = 0
The above code crashes the event manager. When I change the "=" in "if (maxPrereqs = 1)" to a ">", it doesn't crash but still draws all prereqs as icons, rather than drawing them only if there are 2 or more.
I have tried to work my way around it several times, but none of them worked entirely, so I came here for help.