Ahlforn

iview

Jun 17th, 2021
500
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local item = require "item"
  2. local term = require "term"
  3. local component = require "component"
  4. local serialization = require "serialization"
  5.  
  6. local args = {...}
  7.  
  8. print("getting controller")
  9. local cont = component.inventory_controller
  10.  
  11. print("getting stack")
  12. local stack = cont.getStackInSlot(tonumber(args[1]),tonumber(args[2]))
  13.  
  14. if args[3] == "p" then
  15.     print("Reding raw:")
  16.     local ln = ""
  17.     for k,v in ipairs(item.readTagRaw(stack))do
  18.        
  19.         ln = ln .. (tostring(v:byte()))
  20.         for i=1,3 - tostring(v:byte()):len()do ln = ln ..(" ") end
  21.         if v:match("[a-z-A-Z0-9]") then
  22.             ln = ln .. ("["..v.."],")
  23.         else
  24.             ln = ln .. ("   ,")
  25.         end
  26.         if k%16==0 then
  27.             print (ln)
  28.             ln = ""
  29.         end
  30.     end
  31.     print(ln)
  32. end
  33. if args[3] == "r" then
  34.     local s = ""
  35.     for k,v in ipairs(item.readTagRaw(stack))do
  36.         s = s .. "\\" .. tostring(v:byte())
  37.     end
  38.    
  39.     for i = 1, #s, 80 do
  40.         print(s:sub(i,i+79))
  41.     end
  42. end
  43.  
  44. print("Decode NBT")
  45. local tag = item.readTag(stack)
  46.  
  47. print("Serialize NBT")
  48. local d = serialization.serialize(tag)
  49. print("TAG("..tostring(#d).."):")
  50.  
  51. for i = 1, #d, 80 do
  52.     print(d:sub(i,i+79))
  53. end
  54.  
  55.  
  56.  
  57.  
RAW Paste Data