Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p = peripheral.wrap("back") -- Change side as needed.
- rednet.open("left") -- Change side as needed.
- -- Variables that you have to set.
- item = "cobble" -- Item that is in your storage media.
- lower = 1 -- Computer id for exracting computer.
- -- First startup
- if not fs.exists("itemlist") then
- h = fs.open("itemlist", "w")
- h.write("0")
- h.close()
- end
- -- Retreives number of items in storage.
- f = fs.open("itemlist", "r")
- count = f.readAll()
- count = tonumber(count)
- f.close()
- -- Adds to number of items in storgae.
- function3 = function()
- f = fs.open("itemlist", "w")
- f.writeLine(tostring(count))
- f.close()
- end
- -- The function for sorting the item
- function2 = function()
- event, id, amount = os.pullEvent("isort_item")
- count = count + amount
- function3()
- p.sort(0)
- end
- -- The function for updating the monitor.
- function1 = function()
- sender, msg = rednet.receive()
- if msg == "update" then
- rednet.send(sender, item..": "..tostring(count))
- else if sender == lower then
- count = count - msg
- function3()
- print(count.." remaining")
- end
- end
- end
- -- Main running code.
- while true do
- parallel.waitForAny(function1, function2)
- /* For anyone who does not know this function
- allows for two or more functions to run at once */
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement