RogerBacon
Feb 02, 2006, 07:08 PM
I'm looking at the API online at http:///files/modding/PythonAPI/
but it doesn't seem to be undated through the 1.52 patch. For example, it has the getCulture function as:
INT getCulture(PlayerType eIndex)
int (int /*PlayerTypes*/ eIndex)
When I use that setup I get an error saying
Python argument types in
CyCity.getCulture(CyCity)
did not match C++ signature:
getCulture(class CyCity {lvalue}, int)
So, I guess I have 2 questions:
1 Where is an up to date API?
2 How do I use the getCulture function to get a city's culture?
Roger Bacon
Locutus
Feb 02, 2006, 08:51 PM
In this instance at least the API is up-to-date, but you seem to have made a logic error in your code: you're passing a city as argument, you should pass a player index.
Should you encounter this type of error again, the error tells you what you're doing wrong: the first line "CyCity.getCulture(CyCity)" tells you what you're calling the function with: it's called on a city (first CyCity) and also passing a city as argument (second CyCity). The second line (the C++ signature) tells you how the game expects you to call the function: "class CyCity {lvalue}" means the function should be called on a city, as you did (lvalue = left value, as in left of the function name), "int" means the first and in this case only argument should be an integer (and from the API doc you can see that that integer should be a player index -- as several players can have cultural influence over a tile/city).
You do have a point about the API doc not being up-to-date though. The problem is that I maintain it but I've been offline for a while. The current Civ4 source code used internally by Firaxis is unfortunately newer than v1.52 and it seems some notable changes have been made to the API compared to the patch, so if I generate new API documentation now it still won't be accurate for v1.52. I'm afraid you'll have to wait until the next patch before I can update the API doc again (but as far as I can tell very few changes where made to the API between v1.00 and v1.52, so that shouldn't be too big of a problem -- and with error messages like the one you got you should always be able to figure out what the game expects).
RogerBacon
Feb 02, 2006, 09:34 PM
Thank you very much Locutus.
OK, I have it working now:
oldCulture = pCity.getCulture(pCity.getOwner())
Now I want to change the culture:
pCity.changeCulture(iPlayer,newCulture,true)
VOID changeCulture(PlayerType eIndex, INT iChange, BOOL bPlots)
Some quick questions:
1 What does the last bool do? I'm assuming it changes the plot culture as well as the city culture.
2 Is iChange added to the current culture? So if I want to lower the culture it needs to be negative? [Edit] Yes, it needs to be negative if you want to lower it.
Thanks in advance,
Roger Bacon
Locutus
Feb 02, 2006, 10:00 PM
1 What does the last bool do? I'm assuming it changes the plot culture as well as the city culture.
Yeah, pretty much, if true it updates the culture level of the surrounding tiles and updates the borders if needed (though this may in fact happen anyway, the code is a bit confusing -- you'd have to experiment with it a bit to figure out the difference, if any).
2 Is iChange added to the current culture? So if I want to lower the culture it needs to be negative?
Yes and yes.
The Great Apple
Feb 03, 2006, 06:21 AM
There is a more reliable API located here (http://sthurlow.com/cvDocs/)