Make Function Delay 5700 The First Time, And 5000 The Other Times

I have a function where I need it to delay 5700 the first time and then 5000 every other time after, that will go on forever. How can I do this? 

Here is my code now:

[lua]

local function updateBlock1s()

brick1:removeSelf()

end

timer.performWithDelay(5700, updateBlock1s, -1)

[/lua]

local delay = 5700 local function updateBlock1s() delay = 5000 brick1:removeSelf() end timer.performWithDelay(delay, updateBlock1s, -1)

I tried it, but it doesnt seem to work.

local delay = 5700 local function updateBlock1s() delay = 5000 brick1:removeSelf() end timer.performWithDelay(delay, updateBlock1s, -1)

I tried it, but it doesnt seem to work.

– TimeSwitch with delay: (Remeber to remove the RuntimeEventListener() when you´re done)

local updateBlock1 = {}

local updateBlock2 = {}

local updateTimer =  {}

local gameTimer =    {}

local switch = true

updateBlock1 = function()

    print(“I´m inside updateBlock 1 with delay=5700”)

    switch = true

end

updateBlock2 = function()

    print(“I´m inside updateBlock 2 with delay=5000”)

    switch = false

end

updateTimer = function()

    local delay

    if ( switch == false ) then 

        delay = 5700

        gameTimer = timer.performWithDelay(delay, updateBlock1, 1)

    elseif ( switch == true ) then

        delay = 5000 

        gameTimer = timer.performWithDelay(delay, updateBlock2, 1)        

    end

end

Runtime:addEventListener(“enterFrame”, updateTimer)

–[[

Then you can just adjust the delay and put the brick:removeSelf or whatever you like inside the different functions

Hope this helps you out

–]]

– TimeSwitch with delay: (Remeber to remove the RuntimeEventListener() when you´re done)

local updateBlock1 = {}

local updateBlock2 = {}

local updateTimer =  {}

local gameTimer =    {}

local switch = true

updateBlock1 = function()

    print(“I´m inside updateBlock 1 with delay=5700”)

    switch = true

end

updateBlock2 = function()

    print(“I´m inside updateBlock 2 with delay=5000”)

    switch = false

end

updateTimer = function()

    local delay

    if ( switch == false ) then 

        delay = 5700

        gameTimer = timer.performWithDelay(delay, updateBlock1, 1)

    elseif ( switch == true ) then

        delay = 5000 

        gameTimer = timer.performWithDelay(delay, updateBlock2, 1)        

    end

end

Runtime:addEventListener(“enterFrame”, updateTimer)

–[[

Then you can just adjust the delay and put the brick:removeSelf or whatever you like inside the different functions

Hope this helps you out

–]]