Advertisement
tmkop

Storage Scanner

Apr 22nd, 2025 (edited)
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. os.loadAPI("/api/tbl.lua")
  2.  
  3. local cx,cy = term.getCursorPos()
  4. term.setCursorPos(cx,cy)
  5. term.write("00.00%")
  6.  
  7. local periphs = peripheral.getNames()
  8. local chests = {}
  9. local fullChests = {}
  10.  
  11. local chest_perifs = {}
  12.  
  13. for i,p_id in ipairs(periphs) do
  14.     local p = peripheral.wrap(p_id)
  15.     if peripheral.hasType(p,"inventory") then
  16.         if p.size() == 54 then
  17.             chest_perifs[#chest_perifs+1] = p
  18.         end
  19.         if #p.list() == 54 then
  20.             fullChests[#fullChests+1] = p_id
  21.         end
  22.     end
  23. end
  24.  
  25. for i,p in ipairs(chest_perifs) do
  26.    
  27.     for slot=1,54 do
  28.         local data = p.getItemDetail(slot)
  29.         if data then
  30.             data["inventory"] = peripheral.getName(p)
  31.             data["slot"] = slot
  32.  
  33.             local small_data = {
  34.                 ["name"] = data["name"],
  35.                 ["count"] = data["count"],
  36.                 ["maxCount"] = data["maxCount"],
  37.                 ["displayName"] = data["displayName"],
  38.                 ["inventory"] = data["inventory"],
  39.                 ["slot"] = data["slot"] }
  40.  
  41.             chests[#chests+1] = small_data
  42.            
  43.         end
  44.  
  45.         term.setCursorPos(cx,cy)
  46.         term.write(math.floor((((i*54)+slot)/((#chest_perifs+1)*54))*10000)/100,"%")
  47.  
  48.     end
  49. end
  50.  
  51.  
  52. term.setCursorPos(cx,cy)
  53. term.write("scan complete")
  54. print("")
  55.  
  56. tbl.save(fullChests,"insertionBlacklist.dat")
  57. tbl.save(chests,"chestData.dat")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement