Valkrionn
The Hamster King
I know exactly what you mean. I may not have a child of my own, but I AM a godfather to my best friend's child... So I've got a decent idea.
If your current python file doesn't already do it, then first:
Code:import CvScreensInterface
Then wherever you want to show the screen:
Code:CvScreensInterface.showTechChooser()
do you know an easy python+XML-only way of creating global variable to stock data for display which would be calculated only once a turn throught python ?
Meaning you need to list "Global x" in the function, BEFORE you use it.
cachedValue = None
def getCachedValue():
global cachedValue
if cachedValue is None:
cachedValue = doReallyExpensiveCalculation()
return cachedValue
def clearCachedValue():
global cachedValue
cachedValue = None
def setTearsConstants(self):
absorbed = 0
for i in range (CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_RAW'):
absorbed = absorbed + 1
percent = round (absorbed * 100.0 / CyMap().numPlots(),3)
SdToolKitAdvanced.sdSetGlobal("TEAR","ABSORBTION",percent)
def getAbsorbtionPercent(self):
percent = SdToolKitAdvanced.sdGetGlobal("TEAR","ABSORBTION")
if percent < 0:
percent = 0
return percent
I used the following actually, but I don't know the difference
Would it by any chance be saved ?
Code:def setTearsConstants(self): absorbed = 0 for i in range (CyMap().numPlots()): pPlot = CyMap().plotByIndex(i) if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_RAW'): absorbed = absorbed + 1 percent = round (absorbed * 100.0 / CyMap().numPlots(),3) SdToolKitAdvanced.sdSetGlobal("TEAR","ABSORBTION",percent) def getAbsorbtionPercent(self): percent = SdToolKitAdvanced.sdGetGlobal("TEAR","ABSORBTION") if percent < 0: percent = 0 return percent
Also, would you know hw I could add a new text info under the awakened percent chance one ? (called SRText)
(happy with the new Tear implementation, but I should add ingame infos to mesure the civ working mecanics)
[B]if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SCIONS') and pPlayer.getNumCities() > 0:
[/B]
#figuring spawn chance
fSpawnOdds = cf.doChanceAwakenedSpawn(-1)
fFirstPart = fSpawnOdds / 100
fSecondPart = fSpawnOdds - (fFirstPart * 100)
#/figuring spawn chance
if fFirstPart + fSecondPart > 0:
SRstr = u"<font=2i>%s</font>" %(str(" ") + str(fFirstPart) + str(".") + str(fSecondPart) + str("% "))
screen.setImageButton("Awakenedchance", "Art/Interface/Buttons/Units/Scions/awake.dds", 84, 106, 16, 16, WidgetTypes.WIDGET_GENERAL, -1, -1 )
screen.setText( "SRText", "Background", SRstr, CvUtil.FONT_LEFT_JUSTIFY, 103, 104, 0.5, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
screen.setHitTest( "SRText", HitTestTypes.HITTEST_NOHIT )
else:
screen.hide( "Awakenedchance" )
screen.hide( "SRText" )
#/Awakened display
#Adventurer display
[B]elif pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_GRIGORI') and pPlayer.getNumCities() > 0:
[/B]
#figuring spawn chance
fGrigoriSpawn = (pPlayer.getGrigoriSpawn() / 100)
fGrigoriActual = pPlayer.getGrigoriSpawn()
fGrigoriMod = (pPlayer.getGrigoriMod() / 100)
fSecondPart = fGrigoriActual - (fGrigoriSpawn * 100)
#/figuring spawn chance
if fGrigoriSpawn > 0:
SRstr = u"<font=2i>%s</font>" %(str(" ") + str(fGrigoriSpawn) + str(".") + str(fSecondPart) + str(" / ") + str(fGrigoriMod) + str(" "))
screen.setImageButton("Adventurerchance", "Art/Interface/Buttons/Units/Adventurer.dds", 167, 7, 16, 16, WidgetTypes.WIDGET_GENERAL, -1, -1 )
screen.setText( "SRText", "Background", SRstr, CvUtil.FONT_LEFT_JUSTIFY, 179, 5, 0.5, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
screen.setHitTest( "SRText", HitTestTypes.HITTEST_NOHIT )
else:
screen.hide( "Adventurerchance" )
screen.hide( "SRText" )
#/Adventurer display
I used the following actually, but I don't know the difference
Would it by any chance be saved ?