GameUtils

OrionVeteran

Deity
Joined
Dec 25, 2003
Messages
2,443
Location
Newport News VA
My Grand Inquisitions mod has several *GameUtils.py files registered with BUG. Each of the functions in all of the files appear to be working, with the exception of the getUpgradePriceOverride function. Other functions in this GameUtils.py file work, but not the getUpgradePriceOverride function. I have only one other GameUtils.py file with this function, which does work. The other file with this function, I can't even get a message box to display. Is there some kind of restriction on the getUpgradePriceOverride function I don't know about? :confused:
 
I have only one other GameUtils.py file with this function, which does work.

...which also overrides the function in the other file.
-> AFAIK (not knowing anything about the BUG structure) every function can only be present once. So just put the stuff in one file.
 
In BUG each version of the GameUtils function is called. So if you have three versions of the canBuild function 4 will be called. Each will be called until one returns true (or whatever) and if none of yours do then the default one is called. At least that is what the documentation says.
 
...which also overrides the function in the other file.
-> AFAIK (not knowing anything about the BUG structure) every function can only be present once. So just put the stuff in one file.

How can an override happen when I have specified override="False" in BUG?

Code:
<!--Orion's Mods start -->
	<!--gameutils -->	
	<gameutils module="AgricultureGameUtils" class="AgricultureGameUtils" override="False"/>	
	<gameutils module="LeonardosWSGameUtils" class="LeonardosWSGameUtils" override="False"/>
	<gameutils module="LimitedReligionsGameUtils" class="LimitedReligionsGameUtils" override="False"/>	
	<gameutils module="ImmigrationGameUtils" class="ImmigrationGameUtils" override="False"/>
	<gameutils module="CombinedForcesGameUtils" class="CombinedForcesGameUtils" override="False"/>
	<gameutils module="OIMGameUtils" class="OIMGameUtils" override="False"/>
	<gameutils module="SlaveCageGameUtils" class="SlaveCageGameUtils" override="False"/>
	<gameutils module="SlaveAuctionGameUtils" class="SlaveAuctionGameUtils" override="False"/>
	<gameutils module="SphinxGameUtils" class="SphinxGameUtils" override="False"/>	
	<gameutils module="LawEnforcementGameUtils" class="LawEnforcementGameUtils" override="False"/>

Putting all of the "stuff" in one file defeats the purpose of modular code.
 
It runs each until one returns a value that is different from the default value, then it stops calling them.

The default value for getUpgradePriceOverride is -1. If you have one that is always returning a value that is not -1 then the ones that would be called after that one are never called since you already got a non-default answer. If the function is not changing the price then it needs to return -1, not the normal price.

My guess is that your Leonardo's Workshop (LeonardosWSGameUtils) is always returning a calculated price (since the typical function of that is to reduce the upgrade price) even if the calculation is just duplicating what the regular upgrade price would be.
 
Top Bottom