Advertisement
jubjub727

Untitled

Feb 25th, 2023
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. local clients = peripheral.call("back", "getNamesRemote")
  2.  
  3. local chests = {}
  4.  
  5. local items = {}
  6.  
  7. local function DiscoverChests()
  8. for k,client in pairs(clients) do
  9. if (string.sub(peripheral.getType(client), 1, 19) == "minecraft:ironchest") then
  10. table.insert(chests, client)
  11. end
  12. end
  13. end
  14.  
  15. DiscoverChests()
  16.  
  17. for _k,chest in pairs(chests) do
  18. local chestP = peripheral.wrap(chest)
  19. for k,item in pairs(chestP.list()) do
  20. local itemTable = {}
  21. itemTable.metaData = item.getMetadata()
  22. itemTable.displayName = itemTable.metaData.displayName
  23. itemTable.name = item.name
  24. itemTable.count = item.count
  25. itemTable.chest = chest
  26. end
  27. end
  28.  
  29. for k,v in pairs(items) do
  30. print(v.name..": "..v.count)
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement