John@44
|
1 local pairs=pairs
|
John@44
|
2 local type=type
|
John@44
|
3 local getmetatable=getmetatable
|
John@44
|
4 local setmetatable=setmetatable
|
John@44
|
5
|
John@44
|
6 setfenv(1,bsk)
|
John@44
|
7
|
John@44
|
8 -- These two functions properly format the call to AceConsole:Print(), which
|
John@44
|
9 -- needs a full object. Calling "Print" will call the mixed-in console functions
|
John@44
|
10 -- but without a self parameter because of the namespacing. I would disembed
|
John@44
|
11 -- console, except that it has handy OnDisable behavior to disable chat
|
John@44
|
12 -- commands.
|
John@44
|
13 function print(...)
|
John@44
|
14 bsk:Print(...)
|
John@44
|
15 end
|
John@44
|
16
|
John@44
|
17 function printf(...)
|
John@44
|
18 bsk:Printf(...)
|
John@44
|
19 end
|
John@44
|
20
|
John@44
|
21 function tcopy(to, from)
|
John@44
|
22 for k,v in pairs(from) do
|
John@44
|
23 if(type(v)=="table") then
|
John@44
|
24 to[k] = {}
|
John@44
|
25 tcopy(to[k], v);
|
John@44
|
26 else
|
John@44
|
27 to[k] = v;
|
John@44
|
28 end
|
John@44
|
29 end
|
John@44
|
30 end
|
John@44
|
31
|
John@44
|
32 function shallowCopy(t)
|
John@44
|
33 local u = { }
|
John@44
|
34 for k, v in pairs(t) do u[k] = v end
|
John@44
|
35 return setmetatable(u, getmetatable(t))
|
John@44
|
36 end
|
John@44
|
37
|
John@44
|
38 function PrintTable(table, depth)
|
John@44
|
39 depth = depth or ""
|
John@44
|
40 if not table then return end
|
John@44
|
41 if #depth > 3*5 then print(depth.."Recursion too deep - stopping"); return end
|
John@44
|
42 for i,v in pairs(table) do
|
John@44
|
43 if( type(v) == "string" ) then
|
John@44
|
44 print(depth .. i .. " - " .. v)
|
John@44
|
45 elseif( type(v) == "number" ) then
|
John@44
|
46 print(depth .. i .. " - " .. tostring(v))
|
John@44
|
47 elseif( type(v) == "table" ) then
|
John@44
|
48 print(depth .. i .." - ")
|
John@44
|
49 PrintTable(v,depth.." ")
|
John@44
|
50 elseif( type(v) == "boolean" ) then
|
John@44
|
51 print(depth .. i .. " - " .. tostring(v))
|
John@44
|
52 elseif( type(v) == "function" ) then
|
John@44
|
53 print(depth .. "function " .. i .. "()")
|
John@44
|
54 else
|
John@44
|
55 print(depth .. i .. " - not sure how to print type: " .. type(v) )
|
John@44
|
56 end
|
John@44
|
57 end
|
John@44
|
58 end
|
John@44
|
59
|