forked from Hydra9268/ZGESO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSlashCommands.lua
More file actions
97 lines (82 loc) · 2.7 KB
/
SlashCommands.lua
File metadata and controls
97 lines (82 loc) · 2.7 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
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
local ZGV = _G.ZGV
-----------------------------------------
-- INFORMATION
-----------------------------------------
-----------------------------------------
-- LOCAL REFERENCES
-----------------------------------------
local tinsert,tremove,sort,min,max,floor,type,pairs,ipairs = table.insert,table.remove,table.sort,math.min,math.max,math.floor,type,pairs,ipairs
local print = ZGV.print
local L = ZGV.L
-----------------------------------------
-- LOCAL VARIABLES
-----------------------------------------
local help_string = [[ Options:
reset - Reset Guide Viewer to original position, and settings.
show - Show the Guide Viewer.
hide - Hide the Guide Viewer.
config - Show configuration.
]]
if ZGV.DEV then
help_string = help_string..[[
debug - Toggle debug on and off.
error - Toggle ignore errors. Requires a reload
]]
end
-----------------------------------------
-- SAVED REFERENCES
-----------------------------------------
-----------------------------------------
-- FUNCTIONS
-----------------------------------------
function ZGV.SlashCommandHandler(text) --TODO
local self = ZGV
if text == "debug" then
self.sv.profile.debug = not self.sv.profile.debug
ZGV:Print(("Debug is %s"):format(self.sv.profile.debug and "on" or "off"))
elseif text == "error" then
self.sv.profile.ignoreErrors = not self.sv.profile.ignoreErrors
ZGV:Print("Please reload for errors to get handled properly.")
elseif text == "report" or text=="bug" then
if not ZGV.BugReport then
ZGV:Print("BugReport feature not loaded. Sorry!")
return
end
ZGV.BugReport:ShowReport()
elseif text == "reset" then
ZGV.Viewer:ResetAllViewerSettings()
elseif text == "show" then
ZGV.Viewer:Show_GuideViewer()
elseif text == "hide" then
ZGV.Viewer:Hide_GuideViewer()
elseif text == "config" then
ZGV.Settings:OpenSettings()
else
ZGV:Print(help_string)
end
end
-----------------------------------------
-- LOCAL FUNCTIONS
-----------------------------------------
local function registerSlashCommands()
local SLASH_COMMANDS, zo_loadstring = _G.SLASH_COMMANDS, _G.zo_loadstring
SLASH_COMMANDS["/zgv"] = ZGV.SlashCommandHandler
SLASH_COMMANDS["/zygor"] = SLASH_COMMANDS["/zgv"]
SLASH_COMMANDS["/run"] = SLASH_COMMANDS["/script"]
SLASH_COMMANDS["/re"] = SLASH_COMMANDS["/reloadui"]
SLASH_COMMANDS["/dump"] = function(text)
local f,err = zo_loadstring( ("d(%s)"):format(text) )
if f then
f()
else
local d = _G.d
d("|cffff0000Error:|r "..err)
end
end
end
-----------------------------------------
-- STARTUP
-----------------------------------------
tinsert(ZGV.startups,function(self)
registerSlashCommands()
end)