-
Notifications
You must be signed in to change notification settings - Fork 1
/
UnitAuraIterators.lua
62 lines (47 loc) · 1.3 KB
/
UnitAuraIterators.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
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
local CheckAura;
CheckAura = function( index, debuffSwitch, unit, name, ... )
if ( name ~= nil ) then
return index, name, ...;
end
if ( debuffSwitch ) then
return CheckAura( 41, false, unit, UnitAura( unit, 1, "HARMFUL" ) );
end
return nil;
end
local AuraIterator = function( unit, index )
index = index + 1;
if ( index <= 0 ) then
return nil;
elseif ( index <= 40 ) then
return CheckAura( index, true, unit, UnitAura( unit, index, "HELPFUL" ) );
elseif ( index <= 80 ) then
return CheckAura( index, false, unit, UnitAura( unit, index - 40, "HARMFUL" ) );
end
return nil;
end
local BuffIterator = function( unit, index )
index = index + 1;
if ( index > 0 and index <= 40 ) then
return CheckAura( index, false, unit, UnitAura( unit, index, "HELPFUL" ) );
end
return nil;
end
local DebuffIterator = function( unit, index )
index = index + 1;
if ( index > 0 and index <= 40 ) then
return CheckAura( index, false, unit, UnitAura( unit, index, "HARMFUL" ) );
end
return nil;
end
local UnitAuras = function( unit )
return AuraIterator, unit, 0
end
local UnitBuffs = function( unit )
return BuffIterator, unit, 0;
end
local UnitDebuffs = function( unit )
return DebuffIterator, unit, 0;
end
kCore.UnitAuras = UnitAuras;
kCore.UnitBuffs = UnitBuffs;
kCore.UnitDebuffs = UnitDebuffs;