forked from xod-wow/LiteMount
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SlashCommand.lua
236 lines (199 loc) · 6.21 KB
/
SlashCommand.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
--[[----------------------------------------------------------------------------
LiteMount/SlashCommand.lua
Chat slash command (/litemount or /lmt) and macro maintenance.
Copyright 2011-2021 Mike Battersby
----------------------------------------------------------------------------]]--
local _, LM = ...
--@debug@
if LibDebug then LibDebug() end
--@end-debug@
local L = LM.Localize
local MacroName = "LiteMount"
local MacroText = [[
# Auto-created by LiteMount addon, it is safe to delete or edit this macro.
# To re-create it run "/litemount macro"
/click LM_B1 LeftButton 1
/click LM_B1 LeftButton 0
]]
local function CreateOrUpdateMacro()
local index = GetMacroIndexByName(MacroName)
if index == 0 then
index = CreateMacro(MacroName, "ABILITY_MOUNT_MECHASTRIDER", MacroText)
else
EditMacro(index, nil, nil, MacroText)
end
return index
end
local function IsTrue(x)
if x == nil or x == false or x == "0" or x == "off" then
return false
else
return true
end
end
local COMMANDS = {}
COMMANDS[''] =
function ()
LiteMountOptionsPanel_Open()
end
COMMANDS['macro'] =
function ()
local i = CreateOrUpdateMacro()
if i then PickupMacro(i) end
end
COMMANDS['priority'] =
function (argstr, priority)
local mount = LM.MountRegistry:GetActiveMount()
priority = tonumber(priority)
if mount and priority then
LM.Options:SetPriority(mount, priority)
end
end
COMMANDS['location'] =
function ()
LM.Print(LOCATION_COLON)
for _,line in ipairs(LM.Environment:GetLocation()) do
LM.Print(" " .. line)
end
end
COMMANDS['maps'] =
function (argstr, ...)
local str = table.concat({ ... }, ' ')
for _,line in ipairs(LM.Environment:GetMaps(str)) do
LM.Print(line)
end
end
COMMANDS['continents'] =
function (argstr, ...)
local str = table.concat({ ... }, ' ')
for _,line in ipairs(LM.Environment:GetContinents(str)) do
LM.Print(line)
end
end
COMMANDS['mounts'] =
function (argstr, ...)
if select('#', ...) == 0 then
local m = LM.MountRegistry:GetActiveMount()
if m then m:Dump() end
else
local n = string.lower(table.concat({ ... }, ' '))
local mounts = LM.MountRegistry.mounts:Search(function (m) return string.match(strlower(m.name), n) end)
for _,m in ipairs(mounts) do
m:Dump()
end
end
return true
end
COMMANDS['group'] =
function (argstr, action, arg1, arg2)
if action == "add" and arg1 then
LM.Options:CreateGroup(arg1)
elseif action == "del" and arg1 then
LM.Options:DeleteGroup(arg1)
elseif action == "rename" and arg1 and arg2 then
LM.Options:RenameGroup(arg1, arg2)
elseif action == "list" and arg1 == nil then
local groups = LM.Options:GetGroupNames()
LM.Print(table.concat(groups, ' '))
end
end
COMMANDS['playermodel'] =
function ()
LM.Print("Player model file ID: " .. LM.Environment:GetPlayerModel())
end
COMMANDS['profile'] =
function (argstr)
-- can't use the split args because we need the raw rest of the line
local profileName = argstr:gsub('^profile%s+', '')
if profileName and LM.Options.db.profiles[profileName] then
LM.Options.db:SetProfile(profileName)
LM.Print("Switching to profile: " .. profileName)
else
LM.Print("No profile found with name: " .. profileName)
end
end
COMMANDS['xmog'] =
function (argstr, slotID)
slotID = tonumber(slotID) or 0
local tmSlot = TRANSMOG_SLOTS[slotID*100]
if tmSlot then
local ok, _, _, _, id = pcall(C_Transmog.GetSlotVisualInfo, tmSlot.location)
if ok == true then
LM.Print(format("Transmog appearance ID for slot %d = %s", slotID, tostring(id)))
else
LM.Print("Bad transmog slot number: " .. slotID)
end
end
end
COMMANDS['debug'] =
function (argstr, arg1)
if IsTrue(arg1) then
LM.Print(L.LM_DEBUGGING_ENABLED)
LM.Options:SetDebug(true)
else
LM.Print(L.LM_DEBUGGING_DISABLED)
LM.Options:SetDebug(false)
end
end
COMMANDS['uidebug'] =
function (argstr, arg1)
if IsTrue(arg1) then
LM.Print(BUG_CATEGORY5 .. ' ' .. L.LM_DEBUGGING_ENABLED)
LM.Options:SetUIDebug(true)
else
LM.Print(BUG_CATEGORY5 .. ' ' .. L.LM_DEBUGGING_DISABLED)
LM.Options:SetUIDebug(false)
end
end
COMMANDS['forcefly'] =
function ()
LM.Environment:ForceFlyable()
end
--@debug@
COMMANDS['usable'] =
function ()
LM.Developer:Initialize()
LM.Developer:UpdateUsability()
end
COMMANDS['pi'] =
function ()
LiteMountProfileInspect:Show()
end
COMMANDS['mockdata'] =
function ()
LM.Developer:ExportMockData()
ReloadUI()
end
--@end-debug@
local function PrintUsage()
LM.Print(GAMEMENU_HELP .. ":")
LM.Print(" /litemount priority <0-4>")
LM.Print(" /litemount mounts [<substring>]")
LM.Print(" /litemount maps [<substring>]")
LM.Print(" /litemount continents [<substring>]")
LM.Print(" /litemount location")
LM.Print(" /litemount macro")
LM.Print(" /litemount group add <name>")
LM.Print(" /litemount group del <name>")
LM.Print(" /litemount group list")
LM.Print(" /litemount group rename <oldname> <newname>")
LM.Print(" /litemount playermodel")
LM.Print(" /litemount profile <profilename>")
LM.Print(" /litemount xmog <slotnumber>")
end
LM.SlashCommandFunc = function (argstr)
-- Look, please stop doing this, ok? Nothing good can come of it.
if InCombatLockdown() then
LM.PrintError(ERR_NOT_IN_COMBAT)
return true
end
local args = { strsplit(" ", argstr) }
local cmd = table.remove(args, 1)
if COMMANDS[cmd] then
COMMANDS[cmd](argstr, unpack(args))
return true
else
PrintUsage()
end
return true
end