-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathMultiBotSpell.lua
More file actions
71 lines (58 loc) · 2.71 KB
/
MultiBotSpell.lua
File metadata and controls
71 lines (58 loc) · 2.71 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
MultiBot.getSpellID = function(pInfo)
local tInfo = MultiBot.doSplit(pInfo, "|")
if(string.sub(tInfo[3], 1, 6) == "Hspell") then return string.sub(tInfo[3], 8) end
return 0
end
MultiBot.addSpell = function(pInfo, pName)
local tInfo = MultiBot.doSplit(pInfo, "|")
local tID = MultiBot.getSpellID(pInfo)
if(tID == 0) then return end
local tName, tRank, tIcon = GetSpellInfo(tID)
local tLink = GetSpellLink(tID)
if(tName == nil) then tName = "" end
if(tRank == nil) then tRank = "" end
if(tIcon == nil) then tIcon = "inv_misc_questionmark" end
if(tLink == nil) then tLink = tName end
local tSpell = { tID, tName, tRank, tIcon, tLink }
table.insert(MultiBot.spellbook.spells, tSpell)
MultiBot.spellbook.index = MultiBot.spellbook.index + 1
if(MultiBot.spells[pName] == nil) then MultiBot.spells[pName] = {} end
if(MultiBot.spells[pName][tID] == nil) then MultiBot.spells[pName][tID] = true end
if(MultiBot.spellbook.index < 17) then
MultiBot.setSpell(MultiBot.spellbook.index, tSpell, pName)
end
end
MultiBot.setSpell = function(pIndex, pSpell, pName)
local tIndex = MultiBot.IF(pIndex < 10, "0", "") .. pIndex
local tOverlay = MultiBot.spellbook.frames["Overlay"]
if(pSpell ~= nil) then
local tTitle = MultiBot.IF(string.len(pSpell[2]) > 16, string.sub(pSpell[2], 1, 16) .. "...", pSpell[2])
tOverlay.setButton("S" .. tIndex, pSpell[4], pSpell[5])
tOverlay.setText("T" .. tIndex, "|cffffcc00" .. tTitle .. "|r")
tOverlay.setText("R" .. tIndex, "|cff402000" .. pSpell[3] .. "|r")
tOverlay.buttons["S" .. tIndex].spell = pSpell[1]
tOverlay.buttons["C" .. tIndex].spell = pSpell[1]
tOverlay.buttons["S" .. tIndex].doShow()
tOverlay.buttons["C" .. tIndex].doShow()
tOverlay.texts["T" .. tIndex]:Show()
tOverlay.texts["R" .. tIndex]:Show()
tOverlay.buttons["C" .. tIndex]:SetChecked(MultiBot.spells[pName][pSpell[1]])
tOverlay.buttons["C" .. tIndex].doClick = function(pButton)
local tName = pButton.getName()
local tAction = ""
MultiBot.spells[tName][pButton.spell] = MultiBot.IF(MultiBot.spells[tName][pButton.spell], false, true)
pButton:SetChecked(MultiBot.spells[tName][pButton.spell])
for id, state in pairs(MultiBot.spells[tName]) do
if(state == false) then tAction = tAction .. MultiBot.IF(tAction == "", "ss +", ", +") .. id end
end
MultiBot.ActionToTarget(MultiBot.IF(tAction == "", "ss -" .. pButton.spell, tAction), tName)
end
else
tOverlay.buttons["S" .. tIndex].spell = 0
tOverlay.buttons["C" .. tIndex].spell = 0
tOverlay.buttons["S" .. tIndex].doHide()
tOverlay.buttons["C" .. tIndex].doHide()
tOverlay.texts["T" .. tIndex]:Hide()
tOverlay.texts["R" .. tIndex]:Hide()
end
end