A python question

JustATourist

Lost in Translation
Joined
Apr 13, 2008
Messages
445
Location
Lower Saxony
I tried to mod my game so that it will play movies every time when I build a national wonder. There was a discription how to mod python in the Wondermovie thread: http://forums.civfanatics.com/showthread.php?t=277651&page=4

I tried to do it this way, and my code now looks this way:
Spoiler :
PHP:
	def onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		game = gc.getGame()
		if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType())):
			# If this is a wonder...
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_PALACE") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_IRON_WORKS") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_HERMITAGE") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDINGCLASS_GLOBE_THEATRE") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_HEROIC_EPIC") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_MOAI_STATUES") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")			
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_MT_RUSHMORE") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_NATIONAL_EPIC") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_NATIONAL_PARK") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_OXFORD_UNIVERSITY") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_RED_CROSS") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_GREAT_PALACE") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_WALL_STREET") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_WEST_POINT") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_MILITARY_ACADEMY") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_ACADEMY") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
	

		if ( iBuildingType==gc.getInfoTypeForString("BUILDING_SCOTLAND_YARD") ):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())

		CvAdvisorUtils.buildingBuiltFeats(pCity, iBuildingType)
I have been very carefull and used copy and paste, so I won't accidently place a wrong tab or space. But what I got when I started a new game was quite surprising: For some building the movies are shown (for example heroic and national epic, forbidden palasce, oxford university,...) and for some they are not (for example iron works, wall street, globe theatre,...).

Well, I could understand, if all movies are played or if none is played. I even could understand, if only the first or the last movies would play, so I would have made a mistake in between, but they are quite mixed. Because I used copy and paste, I don't believe that there are some wrong tabs (there was somebody who had this problem before, so I have been very careful).

Has anybody an idea, what the reason might be and how to fix it? I have attached my modded file, if anybody want to have a look, what might be wrong.
 

Attachments

Could it be another mistake ? Say a typo in the movie defnitions/paths for the wonders that do not play ?

Otherwise - try change the wonder-block order (They are identical so you only need to switch the "BUILDING_XXXXX" identifiers)... Let say switch Heroic Epic and Ironworks... If still HE does show but IW does not, then nothing is wrong with your python... Otherwise (if not HE does not work but IW does) it's probably a bad block indentation... Good luck searching the rougue tab then :(
 
Could it be another mistake ? Say a typo in the movie defnitions/paths for the wonders that do not play ?

I don't think so. Otherwise I would get a window for the movie but filled with pink color. But the window itself isn't shown.

Otherwise (if not HE does not work but IW does) it's probably a bad block indentation... Good luck searching the rougue tab then :(

Well, thanks. :)
 
Maybe I missed something, why does this need to be done in python?

Why not just use the xml tags? In BuildingInfos:
<MovieDefineTag>ART_DEF_MOVIE_CIRCUS</MovieDefineTag>

and the match is over in Art/CIV4ArtDefines_Movie.xml

Code:
		<MovieArtInfo>
			<Type>ART_DEF_MOVIE_CIRCUS</Type>
			<Path>Art/Interface/Buttons/popups/circus.dds</Path>
		</MovieArtInfo>
		<MovieArtInfo>
			<Type>ART_DEF_MOVIE_HAGIA_SOPHIA</Type>
			<Path>Art/Movies/Wonders/HagiaSophia.bik</Path>
		</MovieArtInfo>
 
The tags must be used as well (and this is where is suspect the mistake to be, because i dont see any in python)

However, the python interface must be changed, because by default it will not play movies on anything but wonders
 
Back
Top Bottom