Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions CompactRaidFrame/Dependence/C_TimerAugment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ local TickerMetatable = {
};

C_Timer = CreateFrame("Frame", "C_Timer");
C_Timer.schedule = {};
C_Timer:Hide()
C_Timer.schedule = {}
C_Timer:SetScript("OnUpdate", function(self, elapsed)
for timestamp, callback in pairs(self.schedule) do
if timestamp <= GetTime() then
callback();
self.schedule[timestamp] = nil;
for k, v in pairs(self.schedule) do
if v.timestamp <= GetTime() then
v.callback()
self.schedule[k] = nil
end
end
if #C_Timer.schedule == 0 then
C_Timer:Hide() -- stop OnUpdate
end
end)

C_Timer.After = function(duration, callback)
C_Timer.schedule[GetTime() + duration] = callback;
table.insert(C_Timer.schedule, {timestamp=GetTime() + duration, callback=callback})
C_Timer:Show() -- start OnUpdate
end

--Creates and starts a ticker that calls callback every duration seconds for N iterations.
Expand Down