-
Notifications
You must be signed in to change notification settings - Fork 1
/
Util.lua
44 lines (40 loc) · 906 Bytes
/
Util.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
local Utils = {}
function Utils:GetNumSpellBookItems()
local t = GetNumSpellTabs()
local n
while true do
local name, texture, offset, numSpells = GetSpellTabInfo(t)
if not name then
break
end
n = offset + numSpells
t = t + 1
end
return n
end
function Utils:FindSpell(name)
name = string.lower(name)
if name == "trinket 1" then
return nil, "Trinket 1"
elseif name == "trinket 2" then
return nil, "Trinket 2"
end
local slot_id = 1
for slot_id = 1, self:GetNumSpellBookItems() do
local full_name = GetSpellBookItemName(slot_id, BOOKTYPE_SPELL)
if not full_name then return nil end
if string.lower(full_name) == name then
return slot_id, full_name
end
end
return nil
end
function Utils:FindFirstSpell(spells)
for _, spell in ipairs(spells) do
local slot, name = Utils:FindSpell(spell)
if slot then
return slot, name
end
end
end
GuiBarHero.Utils = Utils