How to fire an event two turns later?
Posted: Thu Dec 26, 2019 8:04 pm
Hi, I'd like to make an event which fires two turns after it was triggered. Here is the example:
I thought if I wrote "SetEvent("SpainJoinsWar", game.turn +2)" it will be fired two turns later but I was wrong 
Code: Select all
function SpainJoinsWar()
local italy = game:GetFactionById(8)
local spain = game:GetFactionById(15)
local germany = game:GetFactionById(2)
if GetEvent("SpainJoinsWar") == 0
and italy.alliance.id == 2 then
local luck = math.random(1,6)
if luck <= 3 then
ChangeFactionAlignment(game:GetFactionById(15), spain.alliance, math.random(30,50))
SetEvent("SpainJoinsWar", game.turn)
elseif luck == 6 then
ChangeFactionAlignment(game:GetFactionById(15), spain.alliance, - math.random(30,50))
SetEvent("SpainJoinsWar", game.turn)
end
end
end