Well, right now I have following code
Lua Code:
local g_powerError = false
local function doBlink(backdrop)
if g_powerError then return end
g_powerError = true
-- save original center colour and colour to red
local r,g,b = backdrop:GetCenterColor()
backdrop:SetCenterColor( 0.4, 0, 0, 0.9 )
-- make a delayed call to return original colour
zo_callLater(function()
backdrop:SetCenterColor( r, g, b, 0.9 )
zo_callLater(function() g_powerError = false end, 200)
end, 300 )
end
This function can be called in some event handler. It will change color of a control to red for 300ms, but then still will have another 200ms deadtime before it can blink again due to external call. It means that all other calls to doBlink() while it is "working" will be ignored.
What I wanted to do is something like this:
Lua Code:
local g_powerError = false
local function doBlink(backdrop)
if g_powerError then return end
g_powerError = true
-- save original center colour and colour to red
local r,g,b = backdrop:GetCenterColor()
backdrop:SetCenterColor( 0.4, 0, 0, 0.9 )
sleep(300)
backdrop:SetCenterColor( r, g, b, 0.9 )
sleep(200)
g_powerError = false
end
But I guess, that I should either stick with initial zo_callLater version, or simply directly use EVENT_MANAGER to do same work manually and do not abuse global ZO_CallLaterId counter.