Popup producing double foundings

OrionVeteran

Deity
Joined
Dec 25, 2003
Messages
2,443
Location
Newport News VA
I have a python function that is producing double religious foundings and I am not sure why. One religion is founded like choose religions is false (It's not). The other religion is founded correctly with the popup. I want to eliminate the automatic founding of a religion that is without the popup. Here is the last part of the code:

Code:
if xChooseReligion:
if CvPlayer.isHuman():
	# Create Religion Selection Popup
	popupInfo = CyPopupInfo()
	popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
	popupInfo.setData1(iPlayer)								
	popupInfo.setText(CyTranslator().getText(("TXT_KEY_FOUNDED_RELIGION"),()))
											
	# Find all unfounded religions
	for iNewReligion in range(gc.getNumReligionInfos()):
		if not gc.getGame().isReligionFounded(iNewReligion):
			popupInfo.addPythonButton(gc.getReligionInfo(iNewReligion).getDescription(), gc.getReligionInfo(iNewReligion).getButton())
				
	popupInfo.addPopup(1)								
	# Found Selected Religion
	gc.getPlayer(iPlayer).foundReligion(iNewReligion, iNewReligion, True)

My question is: How can I limit the religious founding to that which the individual picks with the popup?

Orion Veteran :cool:
 
Code:
popupInfo.addPopup(1)								
# Found Selected Religion
gc.getPlayer(iPlayer).foundReligion(iNewReligion, iNewReligion, True)

From my very limited understanding of how popups work in Civ, I believe that adding the popup only tells Civ to display the popup once the current Python code finishes running--when it returns back to Civ's event loop.

So you build a popup, schedule it to be shown, and then found whatever religion iNewReligion turns out to be (the last religion in the loop in this case). Then Civ displays your popup, the user chooses a religion, and ... hmm, I don't get it. Civ doesn't know to found a religion here because it's a standard popup type. I'm at a loss.

Try removing the last line I quoted and see what you get.
 
Code:
	popupInfo.addPopup(1)								
	# Found Selected Religion
	gc.getPlayer(iPlayer).foundReligion(iNewReligion, iNewReligion, True)

From my very limited understanding of how popups work in Civ, I believe that adding the popup only tells Civ to display the popup once the current Python code finishes running--when it returns back to Civ's event loop.

So you build a popup, schedule it to be shown, and then found whatever religion iNewReligion turns out to be (the last religion in the loop in this case).

Try removing the last two lines I quoted and see what you get.
 
I solved the problem with the following code:

Code:
for iNewReligion in range(gc.getNumReligionInfos()):
	if not gc.getGame().isReligionFounded(iNewReligion):
		popupInfo.addPythonButton(gc.getReligionInfo(iNewReligion).getDescription(), gc.getReligionInfo(iNewReligion).getButton())
		iRCount = iRCount + 1
		if iRCount == 7 - CivUtil.CvGetTotalReligionsFounded():
			popupInfo.addPopup(1)								
			# Found Selected Religion
			gc.getPlayer(iPlayer).foundReligion(iNewReligion, iNewReligion, True)

I'm not really sure why is works, but it does. Thanks for trying.

Sincerely,

Orion Veteran :cool:
 
Top Bottom