Advertisement
shiroxxblank

sendInventory

Jul 1st, 2022 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. ---@diagnostic disable: undefined-global
  2.  
  3. peripheral.find("modem", rednet.open)
  4.  
  5. local chest = peripheral.find("minecraft:chest")
  6. local lastItems = {}
  7. local items = {}
  8. while true do
  9. local total = 0
  10. items = {}
  11.  
  12. for i = 1, chest.size(), 1 do
  13. total = total + chest.getItemLimit(i)
  14. end
  15.  
  16. for slot, item in pairs(chest.list()) do
  17.  
  18. if items[item.name] ~= nil then
  19. items[item.name] = items[item.name] + item.count
  20. else
  21. items[item.name] = item.count
  22. end
  23. end
  24.  
  25. if items ~= lastItems and items ~= {} then
  26. rednet.send(22, {items, total})
  27. lastItems = items
  28. end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement