A few simple questions about modding.

Just one question from me: can you create building which is built when city's size is X people? If it is possible then we can make this building as prerequisite for this building:
Can a building be made to require the city to have "x" number of citizens before the building can be built?
 
Just one question from me: can you create building which is built when city's size is X people? If it is possible then we can make this building as prerequisite for this building:
That's a good solution, I think, although the processing burden would have to be on every time any city increases population...

There's a relevant GameEvent, SetPopulation, with documentation (mostly inferred, some general info from the modding dev Sseckman) at the official Wiki, at http://wiki.2kgames.com/civ5/index.php/Lua_Game_Objects/GameEvents. Just whenever a city reaches your target size, add the building (I think there's a Lua function to add a building to a city); to be rigorous, you probably want to check if the building is present any time the new pop is greater than or equal to the threshold, and add it if it's absent; make sure the building is non-sellable.
 
What I am trying to do is making new buildings available to a city when the population reaches certain numbers.

I believe its possible through lua to check for city population every turn and check for needed conditions and if check is a pass then building X becomes available in that city. This naturally requires also checks for removing the building option when pop drops again. But this requires a lot of processing every turn on every city which I I want to steer clear of. I was hoping for a simple built-in function that makes this simple.

I'm not 100% sure about the long method I described either. I dont know scripting and therefore not sure whats doable and what not.
 
I believe its possible through lua to check for city population every turn and check for needed conditions and if check is a pass then building X becomes available in that city.

Last I checked, there isn't a "SetIsAvailable" sort of function for buildings, at least not on a city-by-city basis.

The method magzhi proposed would work fine. Create a series of buildings that cost -1, and trap either the city growth GameEvent or just make a start-of-turn event; if a city is size X, then give it all of the hidden buildings up to that size. Then just set any buildings you want to be size-limited to require the appropriate hidden buildings. So if you add BUILDING_SIZE5, BUILDING_SIZE10, and so on, then you'd just make your new building require one of those.

The only real downside to this method is that a player would see in the city's UI this series of buildings. So you'd probably want to name them something appropriate, like "Mayor's Office", "City Hall", "Governor's Mansion", etc. to reflect bigger and bigger cities.
It'd also screw up any functions that keyed off the number of buildings present in a city, but I can't think of any in the vanilla game that work this way.
 
From Sseckman's description of the facilities theoretically available using GameEvents, we may get a CanBuild event down the road, which would really help.
 
Back
Top Bottom