Skip to content

Commit 8814910

Browse files
committed
oUF: scope unitSelectionType
1 parent 9a2ab6b commit 8814910

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

ElvUI_Libraries/Game/Shared/oUF/private.lua

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ local UnitIsVisible = UnitIsVisible
1616
local UnitSelectionType = UnitSelectionType
1717
local UnitThreatSituation = UnitThreatSituation
1818

19+
local validator = CreateFrame('Frame')
20+
1921
function Private.argcheck(value, num, ...)
2022
assert(type(num) == 'number', "Bad argument #2 to 'argcheck' (number expected, got " .. type(num) .. ')')
2123

@@ -44,8 +46,6 @@ function Private.unitExists(unit)
4446
return unit and (UnitExists(unit) or UnitIsVisible(unit))
4547
end
4648

47-
local validator = CreateFrame('Frame')
48-
4949
function Private.validateUnit(unit)
5050
local ok = pcall(UnitHealth, unit)
5151
if not ok then return end
@@ -77,15 +77,17 @@ function Private.isUnitEvent(event, unit)
7777
return isOK
7878
end
7979

80-
local validSelectionTypes = {}
81-
for _, selectionType in next, oUF.Enum.SelectionType do
82-
validSelectionTypes[selectionType] = selectionType
83-
end
80+
do
81+
local validSelectionTypes = {}
82+
for _, selectionType in next, oUF.Enum.SelectionType do
83+
validSelectionTypes[selectionType] = selectionType
84+
end
8485

85-
function Private.unitSelectionType(unit, considerHostile)
86-
if(considerHostile and UnitThreatSituation('player', unit)) then
87-
return 0
88-
else
89-
return validSelectionTypes[UnitSelectionType(unit, true)]
86+
function Private.unitSelectionType(unit, considerHostile)
87+
if(considerHostile and UnitThreatSituation('player', unit)) then
88+
return 0
89+
else
90+
return validSelectionTypes[UnitSelectionType(unit, true)]
91+
end
9092
end
9193
end

0 commit comments

Comments
 (0)