Advertisement
npSim

outTree (new)

Mar 3rd, 2018 (edited)
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. local function bPassesFilter(str)
  2.     local bool = (
  3.         tostring(str) ~= "__index" and
  4.         tostring(str) ~= "__everyclass" and
  5.         tostring(str) ~= "_G" and
  6.         tostring(str) ~= "__module__"
  7.     )
  8.     return bool
  9. end
  10. function outTree(TABLE, key)
  11.     local file = io.open("TreeDump.txt", "w")
  12.     file:close()
  13.     file = io.open("TreeDump.txt", "a+")
  14.     file:write("KEY | "..tostring(key).."\n")
  15.     file:write("input type | "..type(TABLE).."\n")
  16.     file:write("input tostring | "..tostring(TABLE).."\n")
  17.     file:write("input tonumber | "..tostring(tonumber(TABLE)).."\n")
  18.     if type(TABLE) ~= "table" and type(TABLE) ~= "userdata" then
  19.         -- file:write(type(TABLE).."\n")
  20.         -- file:write(tostring(TABLE).."\n")
  21.         log("Tree Error! See TreeDump.txt | " .. tostring(key))
  22.         log("\t TOSTRING | " .. tostring(TABLE))
  23.         return
  24.     elseif type(TABLE) == "userdata" then
  25.         TABLE = getmetatable(TABLE)
  26.     end
  27.     file:write("{}=========="..tostring(TABLE).."=========={}\n")
  28.     local table1 = {}
  29.     local table2 = {}
  30.     local table3 = {}
  31.     for k, v in pairs(TABLE) do
  32.         table1[k] = v
  33.         if v then
  34.             --log(tostring(k))
  35.             file:write(type(v).." | "..tostring(k).."\n")
  36.             if type(v) == "string" or type(v) == "number" or type(v) == "boolean"  then
  37.                 file:write("\tTOSTRING | "..tostring(v).."\n")
  38.             end
  39.         end
  40.         if type(v) == 'table' and bPassesFilter(k) then
  41.        
  42.             for k1, v1 in pairs(v) do
  43.                 table2[k1] = v1
  44.                 if v1 then
  45.                     --log(tostring(k1))
  46.                     file:write("\t"..type(v1).." | "..tostring(k1).."\n")
  47.                     if type(v1) == "string" or type(v1) == "number" or type(v1) == "boolean"  then
  48.                         file:write("\t\tTOSTRING | "..tostring(v1).."\n")
  49.                     end
  50.                 end
  51.                 if type(v1) == 'table' and bPassesFilter(k1) then
  52.                
  53.                     for k2, v2 in pairs(v1) do
  54.                         table3[k2] = v2
  55.                         if v2 then
  56.                             --log(tostring(k2))
  57.                             file:write("\t\t"..type(v2).." | "..tostring(k2).."\n")
  58.                             if type(v2) == "string" or type(v2) == "number" or type(v2) == "boolean"  then
  59.                                 file:write("\t\t\tTOSTRING | "..tostring(v2).."\n")
  60.                             end
  61.                         end
  62.                         if type(v2) == 'table' then
  63.                             file:write("\t\t\t <<<THERES MORE>>>\n")
  64.                         end
  65.                     end
  66.                 end
  67.             end
  68.         end
  69.     end
  70.     log("Tree Created! See TreeDump.txt | " .. tostring(key))
  71.     file:close()
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement