John@47: local bsk=bsk John@44: local pairs=pairs John@47: local tostring=tostring John@44: local type=type John@62: local table=table John@44: local getmetatable=getmetatable John@44: local setmetatable=setmetatable John@44: John@44: setfenv(1,bsk) John@44: John@44: -- These two functions properly format the call to AceConsole:Print(), which John@44: -- needs a full object. Calling "Print" will call the mixed-in console functions John@44: -- but without a self parameter because of the namespacing. I would disembed John@44: -- console, except that it has handy OnDisable behavior to disable chat John@44: -- commands. John@44: function print(...) John@44: bsk:Print(...) John@44: end John@44: John@44: function printf(...) John@44: bsk:Printf(...) John@44: end John@44: John@44: function tcopy(to, from) John@100: if not from then to = {}; return end John@100: for k,v in pairs(from) do John@100: if(type(v)=="table") then John@100: to[k] = {} John@100: tcopy(to[k], v); John@100: else John@100: to[k] = v; John@100: end John@44: end John@44: end John@44: John@44: function shallowCopy(t) John@44: local u = { } John@44: for k, v in pairs(t) do u[k] = v end John@44: return setmetatable(u, getmetatable(t)) John@44: end John@44: John@62: function PrintTable(tabl, depth, history) John@44: depth = depth or "" John@62: history = history or {} John@62: if not tabl then return end John@44: if #depth > 3*5 then print(depth.."Recursion too deep - stopping"); return end John@62: for i,v in pairs(tabl) do John@44: if( type(v) == "string" ) then John@44: print(depth .. i .. " - " .. v) John@44: elseif( type(v) == "number" ) then John@44: print(depth .. i .. " - " .. tostring(v)) John@44: elseif( type(v) == "table" ) then John@48: --if v == table then return end John@48: print(depth .. tostring(i) .." - ") John@62: if history then John@62: for i,vh in pairs(history) do John@62: if vh==tabl then John@62: print(depth.. " - circular reference detected; halting print") John@62: return John@62: end John@62: end John@62: end John@62: table.insert(history,tabl) John@62: PrintTable(v,depth.." ",history) John@62: table.remove(history) John@44: elseif( type(v) == "boolean" ) then John@44: print(depth .. i .. " - " .. tostring(v)) John@44: elseif( type(v) == "function" ) then John@44: print(depth .. "function " .. i .. "()") John@44: else John@44: print(depth .. i .. " - not sure how to print type: " .. type(v) ) John@44: end John@44: end John@44: end John@44: