-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHelperFunctions.lua
56 lines (52 loc) · 1.97 KB
/
HelperFunctions.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
-- Additional debug info can be found on http://www.wowwiki.com/Blizzard_DebugTools
-- /framestack [showhidden]
-- showhidden - if "true" then will also display information about hidden frames
-- /eventtrace [command]
-- start - enables event capturing to the EventTrace frame
-- stop - disables event capturing
-- number - captures the provided number of events and then stops
-- If no command is given the EventTrace frame visibility is toggled. The first time the frame is displayed, event tracing is automatically started.
-- /dump expression
-- expression can be any valid lua expression that results in a value. So variable names, function calls, frames or tables can all be dumped.
-- Adds message to the chatbox (only visible to the loacl player)
function dout(msg)
DEFAULT_CHAT_FRAME:AddMessage(msg);
end
-- Debug print
function DebugPrint(status, category, level, msg)
if DLAPI then
DLAPI.DebugLog("UnitFramesImproved", "%s~%s~%s~%s", tostring(status), tostring(category), tostring(level), tostring(msg))
else
dout(msg)
end
end
function DebugPrintf(...)
local status, res = pcall(format, ...)
if status then
if DLAPI then
DLAPI.DebugLog("UnitFramesImproved", res)
else
dout(res)
end
end
end
-- Table Dump Functions -- http://lua-users.org/wiki/TableSerialization
function print_r(t, indent, done)
done = done or {}
indent = indent or ''
local nextIndent -- Storage for next indentation value
for key, value in pairs(t) do
if type(value) == "table" and not done[value] then
nextIndent = nextIndent or
(indent .. string.rep(' ', string.len(tostring(key)) + 2))
-- Shortcut conditional allocation
done[value] = true
print(indent .. "[" .. tostring(key) .. "] => Table {");
print(nextIndent .. "{");
print_r(value, nextIndent .. string.rep(' ', 2), done)
print(nextIndent .. "}");
else
print(indent .. "[" .. tostring(key) .. "] => " .. tostring(value) .. "")
end
end
end