[LUA QUESTION] SetBuildingYieldChange

Tryhard Trevor

Chieftain
Joined
Feb 29, 2016
Messages
22
Could anyone provide a better explanation of the SetBuildingYieldChange method? I want to make Libraries for a specific Civ yield culture. So far I've tried city:SetBuildingYieldChange(40, 4, 2), city:SetBuildingYieldChange("BUILDINGCLASS_LIBRARY", "YIELD_CULTURE", 2),
and pCity:SetBuildingYieldChange(BUILDINGCLASS_LIBRARY, YIELD_CULTURE, 2). Nothing seems to be working.
 
You need to input the ID# for Building-Class Library and the ID# for Yield Culture. Example of how to get an ID# for a Building-Class, taken from the wiki for BuildingClassType
Code:
local id = GameInfo.BuildingClasses.BUILDINGCLASS_CATHEDRAL.ID
which would stick the ID# for the Cathedral BuildingClass into variable 'id'.

Alternately, you can just use the GameInfoTypes method and directly state as
Code:
city:SetBuildingYieldChange(GameInfoTypes["BUILDINGCLASS_LIBRARY"], GameInfoTypes["YIELD_CULTURE"], 2)
 
A quick Google returned this topic, which answers your question quite nicely.

As for why your code isn't working, none of us can really help without seeing it for ourselves.

EDIT: ITT: a case study in why you should refresh to see if other people have replied before posting :p
 
Considering both of us linked a topic in which you had the last, and most helpful response, you won the posting war before it had even started :lol:
 
Hey guys. Thanks for all your help, I've gotten some things working, but I'm still having issues. I've been able to change the yield, but only for Gold, and nothing else. My intended goal was to update the culture. This seems to work: pCity:SetBuildingYieldChange(GameInfoTypes.BUILDINGCLASS_LIBRARY, YieldTypes.YIELD_GOLD, 2), giving me 2 extra Gold per turn. When I try this, YieldTypes.YIELD_CULTURE, however, it won't update. The same seems to apply to Faith and Production.
 
This seems to work: pCity:SetBuildingYieldChange(GameInfoTypes.BUILDINGCLASS_LIBRARY, YieldTypes.YIELD_GOLD, 2), giving me 2 extra Gold per turn. When I try this, YieldTypes.YIELD_CULTURE, however, it won't update. The same seems to apply to Faith and Production.

Welcome to the weird, wacky and frustrating world of Firaxis (non-unified) yields.

In the beginning there were four yields - Food, Production, Science and Gold - these tend to behave consistently (although there are a few exceptions). Culture, while appearing to be a yield, was NOT implemented in the same way (and has no entry in the vanilla Yields table)

When G&K came out, Culture was promoted to a yield, BUT the implementation was incomplete - where culture was required by G&K (and later BNW) it works. If you're lucky, other secondary yield tables were hooked up at the same time to accept culture - but not all were. API methods that set yield bonuses are pretty much hit-and-miss as to whether they work or not for Culture - which is the issue you've discovered.

Then there's Faith - the illegitimate child of the Yields table! It's a complete mishmash of the standard yield and specific culture implementations within the C++ code, and, while appearing as a yield, suffers all the same issues as Culture - but when Culture will work, sometimes Faith won't ... and vice-versa.

Finally, there's BNW's Tourism. Implemented pretty much as Culture was originally, and most definitely not a yield.

...

Unless, that is, you're using a modded DLL that supports the Unified Yields code base.
 
And which are the primary reasons why so many of us use dummy buildings rather than direct-lua changes to yields in a city. Though dummy buildings still suffer the irksomeness that some effects will not stack for multiple copies of the same building within the same city.
 
Top Bottom