I have at the moment a problem with BUG, and I can't figure out why.
I hope someone here can help me with that .
The problem is in this thread.
It's a simple modification, which should make that a world wonder is required for a project.
The whole thing works in BtS, but doesn't in BUG.
The related XML is named ManhattanRequiresPentagon.xml, with the content:
The init.xml is also modified:
The content of the related ManhattanRequiresPentagon.py
The events work, and are also registered, like I can see in the PythonDBG.log
I don't see that the callback is somehow loaded:
The cannotCreate callback is NOT deactivated via the PythonCallbackDefines.xml, so that's not the issue.
I think I've read now everything in the tutorial, and I still can't see what I did wrong.
Can anyone guess where I've made a mistake ?
I hope someone here can help me with that .
The problem is in this thread.
It's a simple modification, which should make that a world wonder is required for a project.
The whole thing works in BtS, but doesn't in BUG.
The related XML is named ManhattanRequiresPentagon.xml, with the content:
PHP:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
makes the manhattan project require the pentagon
-->
<mod id="ManhattanRequiresPentagon" module="ManhattanRequiresPentagon">
<event type="cityRazed" function="onCityRazed"/>
<event type="cityAcquiredAndKept" function="onCityAcquiredAndKept"/>
<gameutils/>
</mod>
The init.xml is also modified:
PHP:
<load mod="ManhattanRequiresPentagon"/>
The content of the related ManhattanRequiresPentagon.py
Spoiler :
PHP:
## Sid Meier's Civilization 4
from CvPythonExtensions import *
import BugUtil
gc = CyGlobalContext()
def onCityAcquiredAndKept(argsList):
'City Acquired and Kept'
iOwner,pCity = argsList
###Manhattan requires Pentagon start
if pCity.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_PENTAGON"))>0:
iOldPlayer = iOwner
pOldTeam = gc.getTeam(gc.getPlayer(iOldPlayer).getTeam())
iManhattan = gc.getInfoTypeForString("PROJECT_MANHATTAN_PROJECT")
if pOldTeam.getProjectCount(iManhattan)>0:
pTeam = gc.getTeam(gc.getPlayer(pCity.getOwner()).getTeam())
pTeam.changeProjectCount(iManhattan,1)
pOldTeam.changeProjectCount(iManhattan,-1)
cvProject = gc.getProjectInfo(iManhattan)
sButton = cvProject.getButton()
CyInterface().addMessage(iOldPlayer,False,15,CyTranslator().getText("TXT_KEY_LOST_MANHATTAN",()),'',0,sButton,ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pCity.getX(), pCity.getY(), True,True)
CyInterface().addMessage(pCity.getOwner(),False,15,CyTranslator().getText("TXT_KEY_CONQUERED_MANHATTAN",()),'',0,sButton,ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True)
###Manhattan requires Pentagon end
def onCityRazed(argsList):
'City Razed'
city, iPlayer = argsList
iOwner = city.findHighestCulture()
###Manhattan requires Pentagon start
if city.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_PENTAGON"))>0:
pTeam = gc.getTeam(gc.getPlayer(pCity.getOwner()).getTeam())
iManhattan = gc.getInfoTypeForString("PROJECT_MANHATTAN_PROJECT")
pTeam.changeProjectCount(iManhattan,-1)
CyInterface().addMessage(pCity.getOwner(),False,15,CyTranslator().getText("TXT_KEY_LOST_MANHATTAN",()),'',0,sButton,ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pCity.getX(), pCity.getY(), True,True)
###Manhattan requires Pentagon end
def cannotCreate(argsList):
pCity = argsList[0]
eProject = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
###Manhattan requires Pentagon start
iManhattan = gc.getInfoTypeForString("PROJECT_MANHATTAN_PROJECT")
if eProject == iManhattan:
if pCity.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_PENTAGON"))>0:
cvProject = gc.getProjectInfo(iManhattan)
iPrereqTech = cvProject.getTechPrereq ()
pTeam = gc.getTeam(gc.getPlayer(pCity.getOwner()).getTeam())
if pTeam.isHasTech(iPrereqTech):
return False
else:
return True
else:
return True
###Manhattan requires Pentagon end
return False
The events work, and are also registered, like I can see in the PythonDBG.log
PHP:
19:44:41 DEBUG: BugConfig - loading mod file ManhattanRequiresPentagon
19:44:41 DEBUG: BugInit - loading mod ManhattanRequiresPentagon...
19:44:41 INFO : BugCore - creating uninitialized mod ManhattanRequiresPentagon
19:44:41 DEBUG: BUG: looking up ManhattanRequiresPentagon.onCityRazed
load_module ManhattanRequiresPentagon
19:44:41 DEBUG: BUG: looking up ManhattanRequiresPentagon.onCityAcquiredAndKept
19:44:41 DEBUG: Timer - load mod [ManhattanRequiresPentagon] took 5 ms
19:44:41 DEBUG: Timer - load mod [init] took 1218 ms
I don't see that the callback is somehow loaded:
PHP:
19:44:36 DEBUG: BUG: binding CvGameUtils.CvGameUtils.cannotCreate to <CvGameUtils.CvGameUtils instance at 0x2DF89580>
19:44:36 DEBUG: BugGameUtils - creating callback cannotCreate>
[...]
19:44:36 DEBUG: BugGameUtils - cannotCreate - setting default to False
The cannotCreate callback is NOT deactivated via the PythonCallbackDefines.xml, so that's not the issue.
I think I've read now everything in the tutorial, and I still can't see what I did wrong.
Can anyone guess where I've made a mistake ?