Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Instructions:
- > label set [Factory Name]
- > pastebin get XQ0zrAwW [Program Name]
- > [Program Name]
- --]]
- function findDrawer()
- local compatible = {"storagedrawers:controller"} --only support controller
- for i, item_id in ipairs(compatible) do
- local drawer = peripheral.find(item_id)
- if drawer then return drawer end
- end
- return nil
- end
- function createMessageFromContainer(container)
- local msg = os.getComputerLabel()
- if container then
- for slot, item in pairs(container.list()) do
- msg = msg..("\n%s %d %d"):format(item.name, item.count, container.getItemLimit(slot))
- end
- end
- return msg
- end
- function main()
- peripheral.find("modem", rednet.open)
- while true do
- while not rednet.isOpen() do
- os.sleep(10)
- peripheral.find("modem", rednet.open)
- end
- local drawer = findDrawer()
- local msg = createMessageFromContainer(drawer)
- rednet.broadcast(msg, "ITEM_UPDATE")
- os.sleep(10)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement