I need some help getting into the Civ5 modding scene. I'm trying to add a fairly simple mod that makes culture from buildings based on population rather than being a flat value. As far as I can tell, my lua file isn't being used at all in the game as none of the print statements are showing up in Fire Tuner. Though I'm not sure if it's related, the code also displays somewhat oddly in Modbuddy; there's no ability to contract or expand blocks of code, but if I open another lua file/project (such as The Economy Mod) it shows up fine.
Here's the code I'm using:
Note that Building_CultureChangePerPop is defined and I can reference it fine in firetuner. I also have set the lua file to import into the VFS. I've looked at other bits of lua code and I can't tell what I'm doing wrong.
Here's the code I'm using:
Code:
print("LoadedCulturePerPopulation")
function UpdateCultureRate()
print("Updating City Culture Per Turn from Buildings")
local iPlayer = Players[Game.GetActivePlayer()]
for pCity in iPlayer:Cities() do
pCity:ChangeJONSCultureStored(1) --Simple debug, deleting this laster
local NewCulture = 0
local OldCulture = 0
for row in GameInfo.Building_CultureChangePerPop() do
if pCity:IsHasBuilding(GameInfo.Buildings[row.BuildingType].ID) then
NewCulture += row.Culture * pCity.GetPopulation * pCity.GetCultureRateModifier() / 100
end
end
for row in GameInfo.Buildings() do
if pCity:IsHasBuilding(GameInfo.Buildings[row.BuildingType].ID) then
OldCulture += row.Culture * pCity.GetCultureRateModifier()
end
end
local TotalCulture = NewCulture + OldCulture
-- Every turn we set Culture Per Turn from Buildings to 0 and re-calculate it.
pCity:ChangeJONSCulturePerTurnFromBuildings(-pCity:GetJONSCulturePerTurnFromBuildings())
pCity:ChangeJONSCulturePerTurnFromBuildings(TotalCulture)
end
end
Events.ActivePlayerTurnStart.Add(UpdateCultureRate)
Note that Building_CultureChangePerPop is defined and I can reference it fine in firetuner. I also have set the lua file to import into the VFS. I've looked at other bits of lua code and I can't tell what I'm doing wrong.