robathome

ChestMon - server

Oct 29th, 2025 (edited)
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. local im = peripheral.find("inventoryManager") or error("no IM")
  2. print("inv ready on protocol 'inv'")
  3. rednet.open("left")
  4. while true do
  5. local id,msg,proto = rednet.receive("inv", 10)
  6. if msg == "list" then
  7. local t = im.getItemsChest("north") or {}
  8. local out = {}
  9. for _,v in pairs(t) do
  10. local name = v.displayName or v.name or (v.item and v.item.displayName) or "?"
  11. local count = v.count or (v.item and v.item.count) or 0
  12. out[#out+1] = {name=name, count=count}
  13. end
  14. table.sort(out, function(a,b) return a.name<b.name end)
  15. rednet.send(id, out, "inv")
  16. end
  17. end
  18.  
  19.  
Advertisement
Add Comment
Please, Sign In to add comment