Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- rednet.host("LCTu", "lct_central")
- local Levels = {
- ["Thomas"] = 1,
- ["Paddi"] = 2
- }
- local queue = {}
- local idle = true
- local dest = nil
- dest = "Thomas"
- while true do
- print("Looping.")
- if idle and #queue > 0 then
- print("Accepting a request,")
- idle = false
- local req = table.remove(queue, 1)
- local acc = {type = "accept_sending"}
- rednet.send(req.src, acc, "LCTu")
- dest = req.dest
- end
- local event, id, msg, prot =
- os.pullEvent()
- if event == "rednet_message" and
- prot == "LCTu" then
- print("Received a message.")
- if msg.type == "request_sending" then
- print("Received a new request.")
- local req = {src = id, dest = msg.dest}
- table.insert(queue, req)
- end
- end
- if event == "redstone" and
- rs.getInput("back") then
- print("Items landed.")
- local lvl = 0
- if Levels[dest] ~= nil then
- lvl = Levels[dest]
- end
- print("Destination is "..dest)
- rs.setAnalogOutput("left", lvl)
- os.sleep(0.2)
- rs.setAnalogOutput("left", 0)
- os.sleep(0.2)
- idle = true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement