jkwok678

1st signal control

Nov 9th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. --First computer on the line ID 183 with a wired modem on the top
  2. rednet.open("top")
  3. while true do
  4. local left=rs.getInput("left")
  5. local right=rs.getInput("right")
  6. local senderID,message,protocol=rednet.receive(1)
  7. if left then
  8. os.startTimer(3)
  9. exit = false
  10. while not exit do
  11. event = os.pullEvent()
  12. if event =="timer" then
  13. exit = true
  14. elseif event=="redstone" then
  15. local right = rs.getInput("right")
  16. if right then rs.setOutput("front",true)
  17. rs.setOutput("back",true)
  18. rednet.send(202,"blocked")
  19. exit = true
  20. end
  21. end
  22. end
  23. elseif right then
  24. os.startTimer(3)
  25. exit = false
  26. while not exit do
  27. event = os.pullEvent()
  28. if event =="timer" then
  29. exit = true
  30. elseif event=="redstone" then
  31. local left= rs.getInput("left")
  32. if left then
  33. rs.setOutput("front",true)
  34. rs.setOutput("back",true)
  35. rednet.send(202,"clear")
  36. exit = true
  37. end
  38. end
  39. end
  40. end
  41. if message=="clear" then
  42. rs.setOutput("front",false)
  43. rs.setOutput("back",false)
  44. elseif message=="blocked" then
  45. rs.setOutput("front",true)
  46. rs.setOutput("back",true)
  47. end
Advertisement
Add Comment
Please, Sign In to add comment