Tradition Free Culture Building Messing With UB LUA

Naixatloz

Chieftain
Joined
Jul 18, 2025
Messages
2
Hi there, I'm working on a custom civ with an Amphitheater replacement that uses LUA to convert Food into Culture. The unique building is fully functional and tested, but I discovered a bug where this function does not work if the building was given for free by Tradition.

The relevant portion of the code works by looping through each city, checking to see if it has a "Franchise Location", and if it does adding that city's Food Difference value to a total sum. After the loop ends that sum is then ran through a few calculations and added to the player's culture.

local iEubongFranchise = GameInfoTypes.BUILDING_NAIX_EUBONG_FRANCHISE
function iEubongConvertFoodToCulture(playerID)
local pPlayer = Players[playerID]
if pPlayer:GetCivilizationType() == iCiv and pPlayer:IsAlive() then
if (Teams[pPlayer:GetTeam()]:IsHasTech(GameInfoTypes.TECH_DRAMA)) then
local iEubongRecipePresent = GetPersistentProperty("eubongRecipe")
if iEubongRecipePresent == 1 then
SetPersistentProperty("iGlobalFoodPerTurn", 0)
for pCity in pPlayer:Cities() do
if pCity:GetNumRealBuilding(iEubongFranchise) > 0 then
local iCityFoodPerTurn = pCity:FoodDifference()
local iCurrentFoodPerTurn = GetPersistentProperty("iGlobalFoodPerTurn")
local iGlobalFoodPerTurn = (iCityFoodPerTurn + iCurrentFoodPerTurn)
SetPersistentProperty("iGlobalFoodPerTurn", iGlobalFoodPerTurn)
print(iCityFoodPerTurn)
print(GetPersistentProperty("iGlobalFoodPerTurn"))

end
end
The problem appears to be that "pCity:GetNumRealBuilding(iEubongFranchise) > 0" misses the UB if you got it for free from tradition. During my testing the code plays out start to end and works with any city that has a normally acquired UB.

Has anyone else run into a similar issue? My assumption is that the free culture building tradition gives has a different Building Type ID than the normal version. One thought I had is trying to use the Building Class to identify the UB, rather than the Building Type. Since that's a broader category, I figure that might be the same between the two versions.

I'd appreciate any thoughts or feedback.
 
IIRC GetNumRealBuilding returns the number constructed, GetNumFreeBuilding returns the number gifted and GetNumBuilding returns the sum of those two.

So your code is behaving as expected, you're just using the wrong method
 
Back
Top Bottom