CobraOs

left

Oct 25th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. send = function()
  2. while not redstone.getInput("top") do
  3.   os.queueEvent("randomEvent")
  4.   os.pullEvent()
  5. end
  6. end
  7.  
  8. recieve = function()
  9. while not redstone.getInput("right") do
  10.   os.queueEvent("randomEvent")
  11.   os.pullEvent()
  12. end
  13. end
  14.  
  15.  
  16. sleep = function()
  17. os.sleep(7)
  18. end
  19.  
  20. signal = function()
  21. while not redstone.getInput("top") do
  22.   os.queueEvent("randomEvent")
  23.   os.pullEvent()
  24. end
  25. end
  26.  
  27.  
  28. while true do
  29.  
  30. yes = parallel.waitForAny(send, recieve)
  31. redstone.setOutput("right", false)
  32.  
  33. if yes == 1 then
  34.   redstone.setOutput("right", true)
  35.   os.sleep(1)
  36.   redstone.setOutput("right", false)
  37.   while yes == 1 do
  38.     yes = parallel.waitForAny(signal, sleep)
  39.   end
  40. else
  41.   redstone.setOutput("left", true)
  42.   os.sleep(3)
  43.   yes = 1
  44.   while yes == 1 do
  45.     yes = parallel.waitForAny(signal, sleep)
  46.   end
  47.   redstone.setOutput("left", false)
  48. end
  49.  
  50. end
Add Comment
Please, Sign In to add comment