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