John@47
|
1 local bsk=bsk
|
John@44
|
2 local pairs=pairs
|
John@47
|
3 local tostring=tostring
|
John@44
|
4 local type=type
|
John@62
|
5 local table=table
|
John@44
|
6 local getmetatable=getmetatable
|
John@44
|
7 local setmetatable=setmetatable
|
John@104
|
8 local _G=_G
|
John@44
|
9
|
John@44
|
10 setfenv(1,bsk)
|
John@44
|
11
|
John@44
|
12 -- These two functions properly format the call to AceConsole:Print(), which
|
John@44
|
13 -- needs a full object. Calling "Print" will call the mixed-in console functions
|
John@44
|
14 -- but without a self parameter because of the namespacing. I would disembed
|
John@44
|
15 -- console, except that it has handy OnDisable behavior to disable chat
|
John@44
|
16 -- commands.
|
John@44
|
17 function print(...)
|
John@44
|
18 bsk:Print(...)
|
John@44
|
19 end
|
John@44
|
20
|
John@44
|
21 function printf(...)
|
John@44
|
22 bsk:Printf(...)
|
John@44
|
23 end
|
John@44
|
24
|
John@44
|
25 function tcopy(to, from)
|
John@100
|
26 if not from then to = {}; return end
|
John@100
|
27 for k,v in pairs(from) do
|
John@100
|
28 if(type(v)=="table") then
|
John@100
|
29 to[k] = {}
|
John@100
|
30 tcopy(to[k], v);
|
John@100
|
31 else
|
John@100
|
32 to[k] = v;
|
John@100
|
33 end
|
John@44
|
34 end
|
John@44
|
35 end
|
John@44
|
36
|
John@44
|
37 function shallowCopy(t)
|
John@44
|
38 local u = { }
|
John@44
|
39 for k, v in pairs(t) do u[k] = v end
|
John@44
|
40 return setmetatable(u, getmetatable(t))
|
John@44
|
41 end
|
John@44
|
42
|
John@62
|
43 function PrintTable(tabl, depth, history)
|
John@44
|
44 depth = depth or ""
|
John@62
|
45 history = history or {}
|
John@62
|
46 if not tabl then return end
|
John@44
|
47 if #depth > 3*5 then print(depth.."Recursion too deep - stopping"); return end
|
John@62
|
48 for i,v in pairs(tabl) do
|
John@44
|
49 if( type(v) == "string" ) then
|
John@44
|
50 print(depth .. i .. " - " .. v)
|
John@44
|
51 elseif( type(v) == "number" ) then
|
John@104
|
52 if v > 1331000000 and v < 1349000000 then
|
John@104
|
53 print(depth .. i .. " - " .. tostring(v) .. " " .. _G.date("%m/%d/%y %H:%M:%S", v))
|
John@104
|
54 else
|
John@104
|
55 print(depth .. i .. " - " .. tostring(v))
|
John@104
|
56 end
|
John@44
|
57 elseif( type(v) == "table" ) then
|
John@48
|
58 --if v == table then return end
|
John@48
|
59 print(depth .. tostring(i) .." - ")
|
John@62
|
60 if history then
|
John@62
|
61 for i,vh in pairs(history) do
|
John@62
|
62 if vh==tabl then
|
John@62
|
63 print(depth.. " - circular reference detected; halting print")
|
John@62
|
64 return
|
John@62
|
65 end
|
John@62
|
66 end
|
John@62
|
67 end
|
John@62
|
68 table.insert(history,tabl)
|
John@62
|
69 PrintTable(v,depth.." ",history)
|
John@62
|
70 table.remove(history)
|
John@44
|
71 elseif( type(v) == "boolean" ) then
|
John@44
|
72 print(depth .. i .. " - " .. tostring(v))
|
John@44
|
73 elseif( type(v) == "function" ) then
|
John@44
|
74 print(depth .. "function " .. i .. "()")
|
John@44
|
75 else
|
John@44
|
76 print(depth .. i .. " - not sure how to print type: " .. type(v) )
|
John@44
|
77 end
|
John@44
|
78 end
|
John@44
|
79 end
|
John@44
|
80
|