tekkub / idhitthat forked from lowlee/lowavoidance

WoW Addon - Attack tables are so fucking confusing...

This URL has Read+Write access

idhitthat / idHitThat.lua
100644 53 lines (41 sloc) 1.46 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
local L = setmetatable({}, {__index=function(t,i) return i end})
tek_locale = L
 
---------------------------
-- Basic Panel --
---------------------------
 
local f = CreateFrame("Button", nil, CharacterModelFrame)
f:SetFrameStrata("DIALOG")
f:SetPoint("BOTTOMRIGHT", -4, 25)
f:SetWidth(26) f:SetHeight(26)
 
local icons, onenters, tips = {}, {}, {}
function tek_register(icon, onenter, tip)
table.insert(onenters, onenter)
icons[onenter] = icon
if tip then tips[tip] = true end
end
 
 
local func
f:RegisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", function(self, event, addon)
if addon:lower() ~= "idhitthat" then return end
 
idHitThatDBPC = idHitThatDBPC or 1
func = onenters[idHitThatDBPC]
 
f:SetNormalTexture(icons[func])
 
self:UnregisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", nil)
end)
 
 
local function changetable(self, v)
local diff = type(v) == "number" and v or 1
idHitThatDBPC = idHitThatDBPC + diff
if idHitThatDBPC > #onenters then idHitThatDBPC = 1 end
if idHitThatDBPC < 1 then idHitThatDBPC = #onenters end
func = onenters[idHitThatDBPC]
f:SetNormalTexture(icons[func])
GameTooltip:Hide()
for tip in pairs(tips) do tip:Hide() end
func(self)
end
f:SetScript("OnClick", changetable)
f:SetScript("OnMouseWheel", changetable)
f:SetScript("OnLeave", function() GameTooltip:Hide() for tip in pairs(tips) do tip:Hide() end end)
f:SetScript("OnEnter", function(self, ...) func(self, ...) end)
f:EnableMouseWheel(true)