Genghis.Khan
Person
Another boring Lua questions by another annoying person triying to code in Lua, without any experience or knowdlege...
The purpose of this thread is to sucessfully implement a Ciy Tax System, for the development of the Civilization V Modding Project: Rise and Fall of Empires.
You will unterstand what I am attemping to do (or not) by the following pseudocode:
Utility for Helping:
Function Modiki Links:
City.GetPopulation - http://modiki.civfanatics.com/index.php/City.GetPopulation_(Civ5_API)
The purpose of this thread is to sucessfully implement a Ciy Tax System, for the development of the Civilization V Modding Project: Rise and Fall of Empires.
You will unterstand what I am attemping to do (or not) by the following pseudocode:
Code:
-- Messy code based on the code provided by Hambil in the "Lua - Adding X Culture and Y Faith from Trade Routes" thread at Civilization Fanatics Forum. Thank you again Hambil
local g_bDebug = true
local LowTaxedCities = {}
local GoldToAddIfLowTaxes = city:GetPopulation() / 4
function DoTurn(iPlayer)
pPlayer = Players[iPlayer]
for pCity in pPlayer:Cities() do
pCity.GetPopulation()
if (pPlayer:SomehowCreatedFucntionToCheckIfCityHasLowTaxesViaSliderControl(pCity) and not m_LowTaxedCities[pCity]) then
m_LowTaxedCities[pCity] = true
pCity.ChangeBaseYieldRateFromMisc(GameInfoTypes.YIELD_GOLD, GoldToAddIfLowTaxes)
--pCity.AddFreeBuilding (to add Happiness somehow)
elseif --repeat conditions for No, Medium, High and Very High Taxes
then
m_LowTaxedCities[pCity] = nil
pCity.ChangeBaseYieldRateFromMisc(GameInfoTypes.YIELD_GOLD, -GoldToAddIfLowTaxes)
--pCity.RemoveBuilding (to remove Happiness somehow)
end
end
end
function P_DoTurn(iPlayer)
local bSuccess
local sResult
bSuccess, sResult = pcall(DoTurn, iPlayer)
if (not bSuccess) then
print(sResult)
end
end
GameEvents.PlayerDoTurn.Add(g_bDebug and DoTurn or P_DoTurn)
Utility for Helping:
Function Modiki Links:
City.GetPopulation - http://modiki.civfanatics.com/index.php/City.GetPopulation_(Civ5_API)