You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
671 B

local unpack, select, time
= unpack, select, time
local BestInSlot, L = unpack(select(2, ...))
local Timer = BestInSlot:NewModule("Timer")
function Timer:OnInitialize()
BestInSlot.Timer = self
end
function Timer:NewTimer(interval, func, verifyvalidfunc, timeout, ...)
local startTime = time()
local args = {...}
local timerfunc
timerfunc = function()
if not verifyvalidfunc or verifyvalidfunc() then
func(true, unpack(args))
elseif timeout and time() > (startTime + timeout) then
func(false, unpack(args))
else
C_Timer.After(interval, timerfunc)
end
end
C_Timer.After(interval, timerfunc)
end