Advertisement
Guest User

storagemonitor

a guest
Jan 21st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local sensor = peripheral.wrap("top")
  2. local items = {}
  3. local nItems = 0
  4. local x,pageSize = term.getSize()
  5. local pIndex = 1
  6. local range = 3
  7.  
  8. local function getChest(name,data)
  9. local itemN = data.Name
  10. local count = data.Size
  11. local max = data.MaxStack
  12. if not items.itemN then
  13. items[itemN] = {
  14. count = 0,
  15. space = 0}
  16. end
  17. items[itemN].count = items[itemN].count + count
  18. items[itemN].space = items[itemN].space + max
  19. end
  20.  
  21. local function getChests(name,data)
  22. local chest = sensor.getTargetDetails(name)
  23. if chest then
  24. local slots = chest.Slots
  25. if slots then
  26. table.foreach(slots,getChest)
  27. end
  28. end
  29. end
  30.  
  31. function printInfo(name,data)
  32. if pIndex==pageSize then
  33. sleep(10)
  34. pIndex = 1
  35. end
  36. print(name," - ",data.count)
  37. pIndex = pIndex + 1
  38. end
  39.  
  40. while true do
  41. local chests = sensor.getTargets()
  42. print("Finished getting targets...")
  43. table.foreach(chests,getChests)
  44. table.foreach(items,printInfo)
  45. sleep(10)
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement