Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local protocol = "inventory_main"
- rednet.open("top")
- rednet.host(protocol, "main")
- local inventories = {}
- local function list()
- local l = {}
- for key, inv in pairs(inventories) do
- for key, value in pairs(inv) do
- local name = value["name"] or "unknown"
- l[name] = (l[name] or 0) + value["count"]
- end
- end
- return l
- end
- while true do
- local id, message = rednet.receive(protocol)
- inventories[("%d_%s"):format(message["id"], message["name"])] = message["data"]
- local monitor = peripheral.wrap("down")
- monitor.setTextScale(0.5)
- monitor.clear()
- monitor.setCursorPos(1,1)
- local l = list()
- for name, count in pairs(l) do
- print(name, count)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment