/
AchScreens.lua
36 lines (33 loc) · 1.11 KB
/
AchScreens.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local T, C, L, _ = unpack(select(2, ...))
if C.automation.screenshot ~= true then return end
----------------------------------------------------------------------------------------
-- Take screenshots of Achievements(Based on Achievement Screenshotter by Blamdarot)
----------------------------------------------------------------------------------------
local function TakeScreen(delay, func, ...)
local waitTable = {}
local waitFrame = CreateFrame("Frame", "WaitFrame", UIParent)
waitFrame:SetScript("onUpdate", function (self, elapse)
local count = #waitTable
local i = 1
while (i <= count) do
local waitRecord = tremove(waitTable, i)
local d = tremove(waitRecord, 1)
local f = tremove(waitRecord, 1)
local p = tremove(waitRecord, 1)
if d > elapse then
tinsert(waitTable, i, {d-elapse, f, p})
i = i + 1
else
count = count - 1
f(unpack(p))
end
end
end)
tinsert(waitTable, {delay, func, {...} })
end
local function OnEvent(...)
TakeScreen(1, TakeScreenshot)
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("ACHIEVEMENT_EARNED")
frame:SetScript("OnEvent", OnEvent)