-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathslashcmd.lua
142 lines (115 loc) · 4.31 KB
/
slashcmd.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
---@type string
local _addonName = select(1, ...);
---@type AddonEnv
local _addon = select(2, ...);
SLASH_SPELLCALC1 = "/sc";
SLASH_SPELLCALC2 = "/spellcalc";
SlashCmdList["SPELLCALC"] = function(arg)
if arg == "debug" then
SpellCalc_settings.debug = not SpellCalc_settings.debug;
_addon:PrintWarn("Debug "..(SpellCalc_settings.debug and "active" or "disabled"));
return;
end
if arg == "ub" then
_addon:UpdatePlayerAuras(true);
_addon:UpdatePlayerAuras();
return;
end
if string.find(arg, "^tt") then
local talentOverride = {};
for tripel in string.gmatch(arg, "%d %d+ %d") do
local tree, talent, rank = string.match(tripel, "(%d) (%d+) (%d)");
if tree == nil or talent == nil or rank == nil then
_addon:PrintWarn("tree, talent or rank nil for tripel: "..tripel);
return;
end
local treen = tonumber(tree);
local talentn = tonumber(talent);
local rankn = tonumber(rank);
local name, _, _, _, _, maxRank = GetTalentInfo(treen, talentn);
if rankn > maxRank then
_addon:PrintWarn("Rank " .. rankn .." invalid! Max rank = " .. maxRank);
return;
end
table.insert(talentOverride, {
tree = treen,
talent = talentn,
rank = rankn
});
print("Add talentoverride: "..name.. " "..rankn.."/"..maxRank);
end
if #talentOverride == 0 then
_addon:PrintWarn("No talents specified!");
return;
end
_addon:UpdateTalents(talentOverride);
return;
end
if string.find(arg, "ps") then
local spellId = string.match(arg, "(%d+)");
if spellId == nil then
_addon:PrintWarn("spellId is nil!");
return;
end
local calcedSpell = _addon:GetCurrentSpellData(tonumber(spellId));
if calcedSpell == nil then
_addon:PrintWarn("No current data for spell with ID "..spellId);
return;
end
print("=== Data for spell "..spellId.." ===============");
_addon:PrintTable(calcedSpell);
print("=========================================");
return;
end
if string.find(arg, "cs") then
local spellId = string.match(arg, "(%d+)");
if spellId == nil then
_addon:PrintWarn("spellId is nil!");
return;
end
local calcedSpell = _addon:GetCalcedSpell(tonumber(spellId));
if calcedSpell == nil then
_addon:PrintWarn("No data for spell with ID "..spellId);
return;
end
print("=== Data for spell "..spellId.." ===============");
_addon:PrintTable(calcedSpell);
print("=========================================");
return;
end
if arg == "i" or arg == "info" then
if SpellCalcStatScreen:IsShown() then
SpellCalcStatScreen:Hide();
else
SpellCalcStatScreen:Show();
end
return;
end
if string.find(arg, "dii") then
local iid, slotid = strmatch(arg, "(%d+) (%d+)");
if iid and slotid then
_addon:PrintWarn("Debug equip item "..iid.." into slot "..slotid.."!");
_addon:DebugEquipItem(tonumber(iid), tonumber(slotid));
end
return;
end
if string.find(arg, "dis") then
local slotid, itemLink = strmatch(arg, "(%d+) (.+)");
print(slotid, itemLink);
if itemLink and slotid then
local _, _, Color, Ltype, Id, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, reforging, Name = string.find(itemLink, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?");
_addon:PrintWarn("Debug equip item "..Id.." into slot "..slotid.."!");
_addon:DebugEquipItem(tonumber(Id), tonumber(slotid));
end
return;
end
if string.find(arg, "dab") then
local spellId = strmatch(arg, "(%d+)");
if spellId then
_addon:DebugApplyBuff(tonumber(spellId));
end
return;
end
InterfaceOptionsFrame_OpenToCategory(_addonName);
InterfaceOptionsFrame_OpenToCategory(_addonName);
end