Spocko
Warlord
I'm trying to build a mod called "executive briefing" whereby I announce various useful pieces of information about your civ, such as a city is unhappy, city is about to grow, etc. Similar to Dr. Jiggle's Civ4lerts Mod.
I'm trying to set up a warning for whenever one of my civ's cities falls below 70% of my own culture - that is, my civ is Germany, and whenever a city has less than 70% Germans in it, I want to know about it.
So, at http://www.sthurlow.com/cvDocs/cvDoc/CyCity.htm I find that CyCity has several methods that relate to culture, one of them being calculateCulturePercent(...)
I want to read this value and write an "if" statement similar to the following statement (one of six or seven I've already cobbled together successfully) invoked by CvEventManager's onCityDoTurn:
My ability to edit Python is limited to seeing how others manipulate a variable, and then cut and paste to taste- but I cannot find any code that illustrates how to use calculateCulturePercent, except the following code in CvMainInterface (by which it displays the nationality culture bar in the lower left corner of the city screen):
This example seems to be just what I want, but I don't know how to feed the method "h" - onCityDoTurn already knows what city it is working with, because so many of the methods listed for CyCity are invoked with the "city." prefix.
So, it seemed obvious to try "X = city.calculateCulturePercent()" ... but Py complained that it wasn't getting what C++ expects, namely "calculateCulturePercent(class CyCity {|value|, int).
{sighs} But I don't know how to interpret this error message.
I will appreciate any help on how to use the information at the above noted website - I've already worked with some of the methods that return integers... but what is this particular method returning?
Thanks!!!
Spocko
ps - I've attached a zip of the ExecutiveBriefing.Py file... the code at the bottom is junk regarding this method (I even tried CyPlot's version of calculateCulturePercent...)
I'm trying to set up a warning for whenever one of my civ's cities falls below 70% of my own culture - that is, my civ is Germany, and whenever a city has less than 70% Germans in it, I want to know about it.
So, at http://www.sthurlow.com/cvDocs/cvDoc/CyCity.htm I find that CyCity has several methods that relate to culture, one of them being calculateCulturePercent(...)
I want to read this value and write an "if" statement similar to the following statement (one of six or seven I've already cobbled together successfully) invoked by CvEventManager's onCityDoTurn:
Code:
# Give a periodic status report on which cities are unhappy, but only every other three turns
if ((iturn % 3) == 0):
if (city.angryPopulation(0) > 0):
CyInterface().addMessage(CyGame().getActivePlayer(),True,10,'The people of %s are angry!' %(city.getName()),'',1,'Art/Interface/Population Heads/angrycitizen.dds',ColorTypes(7),city.getX(),city.getY(),True,True)
My ability to edit Python is limited to seeing how others manipulate a variable, and then cut and paste to taste- but I cannot find any code that illustrates how to use calculateCulturePercent, except the following code in CvMainInterface (by which it displays the nationality culture bar in the lower left corner of the city screen):
Code:
for h in range( gc.getMAX_CIV_PLAYERS() ):
if ( gc.getPlayer(h).isAlive() ):
fPercent = pHeadSelectedCity.plot().calculateCulturePercent(h)
fPercent = fPercent / 100.0
if ( fPercent != 0 ):
This example seems to be just what I want, but I don't know how to feed the method "h" - onCityDoTurn already knows what city it is working with, because so many of the methods listed for CyCity are invoked with the "city." prefix.
So, it seemed obvious to try "X = city.calculateCulturePercent()" ... but Py complained that it wasn't getting what C++ expects, namely "calculateCulturePercent(class CyCity {|value|, int).
{sighs} But I don't know how to interpret this error message.
I will appreciate any help on how to use the information at the above noted website - I've already worked with some of the methods that return integers... but what is this particular method returning?
Thanks!!!
Spocko
ps - I've attached a zip of the ExecutiveBriefing.Py file... the code at the bottom is junk regarding this method (I even tried CyPlot's version of calculateCulturePercent...)