Advertisement
fatboychummy

modu-debug.lua

Nov 17th, 2018
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.07 KB | None | 0 0
  1. --[[
  2. {"debug"}
  3. ]]
  4.  
  5. return function (input,chests,inventory,tell,dynaStore,mods,chestCache,allItems)
  6.   local function cSerialize(tb,spc)
  7.     spc = spc or 0
  8.     local i = 1
  9.     local tmp = {}
  10.     if spc == 0 then
  11.       tmp[1] = string.rep(" ",spc) .. "{"
  12.     else
  13.       i = i - 1
  14.     end
  15.     spc = spc + 2
  16.     if type(tb) == "table" then
  17.       for k,v in pairs(tb) do
  18.         i = i + 1
  19.         if type(v) == "table" then
  20.           local tmp2 = cSerialize(v,spc+2)
  21.           tmp[i] = string.rep(" ",spc) .. "[\"" .. k .. "\"] = {"
  22.           i = i + 1
  23.           for o = 1,#tmp2 do
  24.             tmp[i] = tmp2[o]
  25.             i = i + 1
  26.           end
  27.           tmp[i] = string.rep(" ",spc) .. "}"
  28.         elseif type(v) == "string" then
  29.           tmp[i] = string.rep(" ",spc) .. "[\"" .. k .. "\"] = \"" .. v .. "\""
  30.         elseif type(v) == "char" then
  31.           tmp[i] = string.rep(" ",spc) .. "[\"" .. k .. "\"] = \'" .. v .. "\'"
  32.         elseif type(v) == "function" then
  33.           tmp[i] = string.rep(" ",spc) .. "[\"" .. k .. "\"] = FUNCTION"
  34.         elseif type(v) == "thread" then
  35.           tmp[i] = string.rep(" ",spc) .. "[\"" .. k .. "\"] = COROUTINE"
  36.         else
  37.           tmp[i] = string.rep(" ",spc) .. "[\"" .. k .. "\"] = " .. v
  38.         end
  39.       end
  40.     else
  41.       return tostring(tb)
  42.     end
  43.     spc = spc - 2
  44.     if spc == 0 then
  45.       tmp[#tmp+1] = string.rep(" ",spc) .. "}"
  46.     end
  47.     return tmp
  48.   end
  49.  
  50.   if input[2] == "dyna" then
  51.     if input[3] ~= nil then
  52.       if dynaStore[input[3]] then
  53.         tell("Contents of dynaStore for module " .. input[3] .. ":")
  54.         local t = cSerialize(dynaStore[input[3]])
  55.         for i = 1,#t do
  56.           tell(t[i])
  57.         end
  58.       else
  59.         tell("No data in dynaStore for mod " .. tostring(input[3]) .. ":")
  60.       end
  61.     else
  62.       tell("Contents of whole dynaStore: ")
  63.       local t = cSerialize(dynaStore)
  64.       for i = 1,#t do
  65.         tell(t[i])
  66.       end
  67.     end
  68.   elseif input[2] == "get" then
  69.     if input[3] == "modules" then
  70.       tell("These are the connected modules, and the commands to activate them.")
  71.       local t = cSerialize(mods)
  72.       for i = 1,#t do
  73.         tell(t[i])
  74.       end
  75.     elseif input[3] == "itemcache" then
  76.       local count = 0
  77.       local count2 = 0
  78.       local itms = {}
  79.       for k, v in pairs(allItems) do
  80.         for k2, v2 in pairs(v) do
  81.           count2 = count2 + 1
  82.           count = v2.count + count
  83.           itms[v2.Display] = v2.count
  84.         end
  85.       end
  86.       tell("There is a total of " .. tostring(count) .. " items stored currently.")
  87.       tell("There are " .. count2 .." unique items.")
  88.       if input[4] and input[4] == "detailed" then
  89.         tell("This may take a while...")
  90.         for k,v in pairs(itms) do
  91.           tell(k .. ": " .. v)
  92.         end
  93.       end
  94.     elseif input[3] == "chestcache" then
  95.  
  96.     else
  97.       tell("I do not understand wat de faq u want u dum shit")
  98.     end
  99.   elseif input[2] == "repeat" then
  100.     tell("\\. "..table.concat(input," "))
  101.   else
  102.     tell("No debug: "..tostring(input[2]))
  103.   end
  104.  
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement