Does this Lua work for Events and Decisions?

Keniisu

YouTuber | Modder
Joined
Dec 17, 2015
Messages
501
Location
United States
I made a LUA code for a Decision which requires 300 Gold :c5gold: and gives +2 Happiness :c5happy: 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
 
pPlayer:ChangeExtraHappinessPerCity(+2)
You don't need a '+'-sign there, it'll cause an error to show up. Only negative numbers need an extra sign in front of them! (the minus (-) sign, like you did with ChangeGold(-iCost)!)
As for the rest of the code... I have no clue, I haven't modded within E&D myself yet (though I plan to in the (near) future!)
 
Back
Top Bottom