local im = peripheral.find("inventoryManager") or error("no IM")
print("inv ready on protocol 'inv'")
rednet.open("left")
while true do
local id,msg,proto = rednet.receive("inv", 10)
if msg == "list" then
local t = im.getItemsChest("north") or {}
local out = {}
for _,v in pairs(t) do
local name = v.displayName or v.name or (v.item and v.item.displayName) or "?"
local count = v.count or (v.item and v.item.count) or 0
out[#out+1] = {name=name, count=count}
end
table.sort(out, function(a,b) return a.name<b.name end)
rednet.send(id, out, "inv")
end
end
Comments