Keniisu
YouTuber | Modder
I made a LUA code for a Decision which requires 300 Gold
and gives +2 Happiness
per city. I'd like to know if it will work or not how I coded it.


Code:
----------------------------------
-- Singapore Decisions
----------------------------------
local iCost = 300
local pPlayer:GetGold
local Decisions_SingaporeStableJobs = {}
Decisions_SingaporeStableJobs.Name = "TXT_KEY_DECISIONS_SINGAPORESTABLEJOBS"
Decisions_SingaporeStableJobs.Desc = "TXT_KEY_DECISIONS_SINGAPORESTABLEJOBS_DESC"
HookDecisionCivilizationIcon(Decisions_SingaporeStableJobs, "CIVILIZATION_HM_SINGAPORE")
Decisions_SingaporeStableJobs.CanFunc = (
function(pPlayer)
if pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_HM_SINGAPORE then return false, false end
if load(pPlayer, "Decisions_SingaporeStableJobs") == true then
Decisions_SingaporeStableJobs.Desc = Locale.ConvertTextKey("TXT_KEY_SINGAPORESTABLEJOBS_ENACDESC")
return false, false, true
end
if (pPlayer:GetGold() >= iCost) and (pPlayer:GetCapitalCity() ~= nil) then
return true, true
else
return true, false
end
end
)
Decisions_SingaporeStableJobs.DoFunc = (
function(pPlayer)
local iCost = math.ceil(300 * iMod)
pPlayer:ChangeGold(-iCost)
pPlayer:ChangeExtraHappinessPerCity(+2)
save(pPlayer, "Decisions_SingaporeStableJobs", true)
end
)
tDecisions.Decisions_SingaporeStableJobs = Decisions_SingaporeStableJobs