-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBattleCraft_ArenaCountDown.lua
More file actions
87 lines (75 loc) · 2.77 KB
/
BattleCraft_ArenaCountDown.lua
File metadata and controls
87 lines (75 loc) · 2.77 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
-- /script countdown = 60
local hidden = false;
local countdown = -1;
local ACDFrame = CreateFrame("Frame", "ACDFrame", UIParent)
function ACDFrame:OnEvent(event, ...) -- functions created in "object:method"-style have an implicit first parameter of "self", which points to object
self[event](self, ...) -- route event parameters to LoseControl:event methods
end
ACDFrame:SetScript("OnEvent", ACDFrame.OnEvent)
ACDFrame:RegisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL")
local ACDNumFrame = CreateFrame("Frame", "ACDNumFrame", UIParent)
ACDNumFrame:SetHeight(256)
ACDNumFrame:SetWidth(256)
ACDNumFrame:SetPoint("CENTER", 0, 128)
ACDNumFrame:Show()
local ACDNumTens = ACDNumFrame:CreateTexture("ACDNumTens", "HIGH")
ACDNumTens:SetWidth(256)
ACDNumTens:SetHeight(128)
ACDNumTens:SetPoint("CENTER", ACDNumFrame, "CENTER", -48, 0)
local ACDNumOnes = ACDNumFrame:CreateTexture("ACDNumOnes", "HIGH")
ACDNumOnes:SetWidth(256)
ACDNumOnes:SetHeight(128)
ACDNumOnes:SetPoint("CENTER", ACDNumFrame, "CENTER", 48, 0)
local ACDNumOne = ACDNumFrame:CreateTexture("ACDNumOne", "HIGH")
ACDNumOne:SetWidth(256)
ACDNumOne:SetHeight(128)
ACDNumOne:SetPoint("CENTER", ACDNumFrame, "CENTER", 0, 0)
ACDFrame:SetScript("OnUpdate", function(self, elapse )
if (countdown > 0) then
hidden = false;
if ((math.floor(countdown) ~= math.floor(countdown - elapse)) and (math.floor(countdown - elapse) >= 0)) then
local str = tostring(math.floor(countdown - elapse));
if (math.floor(countdown - elapse) == 0) then
ACDNumTens:Hide();
ACDNumOnes:Hide();
ACDNumOne:Hide();
elseif (string.len(str) == 2) then
-- Display has 2 digits
ACDNumTens:Show();
ACDNumOnes:Show();
ACDNumTens:SetTexture("Interface\\AddOns\\BattleCraft_ArenaCountDown\\Artwork\\".. string.sub(str,0,1));
ACDNumOnes:SetTexture("Interface\\AddOns\\BattleCraft_ArenaCountDown\\Artwork\\".. string.sub(str,2,2));
ACDNumFrame:SetScale(0.7)
elseif (string.len(str) == 1) then
-- Display has 1 digit
ACDNumOne:Show();
ACDNumOne:SetTexture("Interface\\AddOns\\BattleCraft_ArenaCountDown\\Artwork\\".. string.sub(str,0,1));
ACDNumOnes:Hide();
ACDNumTens:Hide();
ACDNumFrame:SetScale(1.0)
end
end
countdown = countdown - elapse;
elseif (not hidden) then
hidden = true;
ACDNumTens:Hide();
ACDNumOnes:Hide();
ACDNumOne:Hide();
end
end)
function ACDFrame:CHAT_MSG_BG_SYSTEM_NEUTRAL(arg1)
if (event == "CHAT_MSG_BG_SYSTEM_NEUTRAL") then
if (string.find(arg1, "One minute until the Arena battle begins!")) then
countdown = 61;
return;
end
if (string.find(arg1, "Thirty seconds until the Arena battle begins!")) then
countdown = 31;
return;
end
if (string.find(arg1, "Fifteen seconds until the Arena battle begins!")) then
countdown = 16;
return;
end
end
end