CobraOs

middle

Oct 25th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1.  
  2. right = function()
  3. redstone.setOutput("right", false)
  4. while not redstone.getInput("right") do
  5. os.queueEvent("randomEvent")
  6. os.pullEvent()
  7. end
  8. return "left"
  9. end
  10.  
  11.  
  12. left = function()
  13. redstone.setOutput("left", false)
  14. while not redstone.getInput("left") do
  15. os.queueEvent("randomEvent")
  16. os.pullEvent()
  17. end
  18. return "right"
  19. end
  20.  
  21.  
  22. while true do
  23.  
  24. side = parallel.waitForAny(left, right)
  25.  
  26. if side == 1 then
  27. redstone.setOutput("right", true)
  28. os.sleep(3)
  29. redstone.setOutput("right", false)
  30. end
  31. if side == 2 then
  32. redstone.setOutput("left", true)
  33. os.sleep(3)
  34. redstone.setOutput("left", false)
  35. end
  36.  
  37. end
Advertisement
Add Comment
Please, Sign In to add comment