Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Finding host")
- peripheral.find("modem", rednet.open)
- local id = rednet.lookup("main", "TRAIN")
- if id then
- print("Found my_host at computer #" .. id)
- else
- printError("Cannot find host")
- end
- while true do
- local event, sender, message, protocol = os.pullEvent("rednet_message")
- if protocol == "TRAIN" then
- if message == "GO" then
- local rear = rs.getAnalogueInput("front")
- if rear > 0 then
- rs.setAnalogueOutput("back",15)
- sleep(1)
- rs.setAnalogueOutput("back",0)
- rednet.send(sender,"OK")
- else
- rednet.send(sender,"NF")
- end
- elseif message == "OFF" then
- print("Server disconnecting. Automode turning on")
- while true do
- print("Working on automatic mode")
- local rear = rs.getAnalogueInput("front")
- if rear > 0 then
- sleep(30)
- rs.setAnalogueOutput("back",15)
- sleep(1)
- rs.setAnalogueOutput("back",0)
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement