Code in my module isn't running

NotSoGood

Emperor
Joined
Jan 25, 2009
Messages
1,077
Location
Finland
I have a problem. I have followed the BUG modding guide and I get no warnings when starting the game. And logs show that my module is loaded fine.
Spoiler :
13:12:43 DEBUG: BugConfig - loading mod file NotSoGood
13:12:43 DEBUG: BugInit - loading mod NotSoGood...
13:12:43 INFO : BugCore - creating uninitialized mod NotSoGood
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onLoadGame
load_module NotSoGood

13:12:43 DEBUG: BugEventManager - adding event 'LoadGame'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onGameStart
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onBeginPlayerTurn
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onCombatResult
13:12:43 DEBUG: BugEventManager - adding event 'CombatResult'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onBuildingBuilt
13:12:43 DEBUG: BugEventManager - adding event 'BuildingBuilt'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onProjectBuilt
13:12:43 DEBUG: BugEventManager - adding event 'ProjectBuilt'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onUnitBuilt
13:12:43 DEBUG: BugEventManager - adding event 'UnitBuilt'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onUnitPromoted
13:12:43 DEBUG: BugEventManager - adding event 'UnitPromoted'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onTechAcquired
13:12:43 DEBUG: BugEventManager - adding event 'TechAcquired'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onGoldenAge
13:12:43 DEBUG: BugEventManager - adding event 'GoldenAge'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onCityBuilt
13:12:43 DEBUG: BugEventManager - adding event 'CityBuilt'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onCityGrowth
13:12:43 DEBUG: BugEventManager - adding event 'CityGrowth'
13:12:43 DEBUG: BugUtil - looking up NotSoGood
13:12:43 DEBUG: BugGameUtils - registering NotSoGood
13:12:43 DEBUG: BugGameUtils - cannotMaintain - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - doPillageGold - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - cannotDoCivic - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - canMaintain - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - canDeclareWar - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - cannotTrain - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - doCityCaptureGold - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - getUpgradePriceOverride - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - cannotConstruct - adding NotSoGood handler
13:12:43 DEBUG: Timer - load mod [NotSoGood] took 77 ms
13:12:43 DEBUG: BugConfig - loading mod file NotSoGoodSettings
13:12:43 DEBUG: BugInit - loading mod NotSoGoodSettings...
13:12:43 INFO : BugCore - creating uninitialized mod NotSoGoodSettings
13:12:43 DEBUG: BugOptions - getNotSoGoodSettings will return IniFile NotSoGoodSettings
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__GoldForDispanding boolean [True]>
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__BetterAirInterception boolean [True]>
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__RangedBombard boolean [True]>
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__RouteAirBombing boolean [True]>
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__AIAlwaysWillingToNegotiate boolean [True]>
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__MaxUnitsPerTile int [0] list (7 ints)>
13:12:43 DEBUG: Timer - load mod [NotSoGoodSettings] took 31 ms
13:12:43 DEBUG: Timer - load mod [init] took 3592 ms
13:12:43 DEBUG: Timer - BUG init [read configs] took 3593 ms
But for some reason, my code in the NotSoGood.py onBuildingBuilt won't run. I haven't tested the others yet, but it seems the GameUtil function are working which are in the same module.
Could someone help me with this?

EDIT: Seems like neither does run my onLoadGame nor onUnitBuilt nor onCombatResult... Only some of them runs. :confused:
 
Check your capitalization. The event is "buildingBuilt", not "BuildingBuilt". (Also "combatResult" not "CombatResult", and so on.) The actual event names are nto consistent - some capitalize the first word, others don't.
 
Assuming my diagnosis is correct (I'm no expert on BUG)...

Probably the easiest way: Go into the base BtS CvEventManager.py file and look at the self.EventHandlerMap list. There are also a few new ones mentioned near the beginning of BugEventManager.py in its __init__ function.

Also, in the output you posted you may notice the lines that say things like "BugEventManager - adding event 'CombatResult'". I expect that this meant that it added a new event type for the capital C version for you (which the DLL, of course, never actually uses). The ones that it added for you are presumably the ones that don't actually get run since they are probably an exact match for the list of the ones that are named wrong.
 
I have a problem. I have followed the BUG modding guide and I get no warnings when starting the game. And logs show that my module is loaded fine.
Spoiler :
13:12:43 DEBUG: BugConfig - loading mod file NotSoGood
13:12:43 DEBUG: BugInit - loading mod NotSoGood...
13:12:43 INFO : BugCore - creating uninitialized mod NotSoGood
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onLoadGame
load_module NotSoGood

13:12:43 DEBUG: BugEventManager - adding event 'LoadGame'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onGameStart
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onBeginPlayerTurn
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onCombatResult
13:12:43 DEBUG: BugEventManager - adding event 'CombatResult'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onBuildingBuilt
13:12:43 DEBUG: BugEventManager - adding event 'BuildingBuilt'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onProjectBuilt
13:12:43 DEBUG: BugEventManager - adding event 'ProjectBuilt'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onUnitBuilt
13:12:43 DEBUG: BugEventManager - adding event 'UnitBuilt'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onUnitPromoted
13:12:43 DEBUG: BugEventManager - adding event 'UnitPromoted'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onTechAcquired
13:12:43 DEBUG: BugEventManager - adding event 'TechAcquired'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onGoldenAge
13:12:43 DEBUG: BugEventManager - adding event 'GoldenAge'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onCityBuilt
13:12:43 DEBUG: BugEventManager - adding event 'CityBuilt'
13:12:43 DEBUG: BugUtil - looking up NotSoGood.onCityGrowth
13:12:43 DEBUG: BugEventManager - adding event 'CityGrowth'
13:12:43 DEBUG: BugUtil - looking up NotSoGood
13:12:43 DEBUG: BugGameUtils - registering NotSoGood
13:12:43 DEBUG: BugGameUtils - cannotMaintain - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - doPillageGold - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - cannotDoCivic - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - canMaintain - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - canDeclareWar - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - cannotTrain - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - doCityCaptureGold - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - getUpgradePriceOverride - adding NotSoGood handler
13:12:43 DEBUG: BugGameUtils - cannotConstruct - adding NotSoGood handler
13:12:43 DEBUG: Timer - load mod [NotSoGood] took 77 ms
13:12:43 DEBUG: BugConfig - loading mod file NotSoGoodSettings
13:12:43 DEBUG: BugInit - loading mod NotSoGoodSettings...
13:12:43 INFO : BugCore - creating uninitialized mod NotSoGoodSettings
13:12:43 DEBUG: BugOptions - getNotSoGoodSettings will return IniFile NotSoGoodSettings
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__GoldForDispanding boolean [True]>
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__BetterAirInterception boolean [True]>
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__RangedBombard boolean [True]>
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__RouteAirBombing boolean [True]>
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__AIAlwaysWillingToNegotiate boolean [True]>
13:12:43 DEBUG: BugOptions - added option <NotSoGoodSettings__MaxUnitsPerTile int [0] list (7 ints)>
13:12:43 DEBUG: Timer - load mod [NotSoGoodSettings] took 31 ms
13:12:43 DEBUG: Timer - load mod [init] took 3592 ms
13:12:43 DEBUG: Timer - BUG init [read configs] took 3593 ms
But for some reason, my code in the NotSoGood.py onBuildingBuilt won't run. I haven't tested the others yet, but it seems the GameUtil function are working which are in the same module.
Could someone help me with this?

EDIT: Seems like neither does run my onLoadGame nor onUnitBuilt nor onCombatResult... Only some of them runs. :confused:
It would be easier to help you if you posted the relevant code. :)
 
GE is correct, and this is a BTS thing unrelated to BUG (kinda). Event types are case-sensitive, and you can find the correct case in CvEventManager for all existing events. When you see that message "adding event ..." it means that BUG is creating a new event for you.

I have BUG create the event automatically because modders can add new events, and requiring them to create the event manually before registering handlers would create ordering dependencies I didn't want. Just check the logs for those lines.
 
Or not... :crazyeye:
 
Top Bottom