Advertisement
Saereth

Redstone Timer while Lever active

Aug 15th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. local INPUT_SIDE = "left" -- change based on where your lever is
  2. local OUTPUT_SIDE = "right" -- change based on where your output side is
  3. local IDLE_TIME = 30 -- time (in sec) for cc to wait, rec 30, allows timer to survive reboot
  4.  
  5. --start an infini8te loop
  6. --hold CTRL+T to stop the program
  7. while true do
  8. --wait for lever to be thrown, or check if red is already active after IDLE_TIME
  9. parallel.waitForAny(function() e = os.pullEvent("redstone"); return true end, function() sleep(IDLE_TIME); return true end)
  10.  
  11. --pulse the output
  12. while rs.getInput(INPUT_SIDE) do--while lever is ON
  13. write(".") --print a dot each time we pulse
  14. rs.setOutput(OUTPUT_SIDE,true)--turn output on
  15. sleep(.2) --wait 0.1 sec
  16. rs.setOutput(OUTPUT_SIDE,false)--turn output off
  17. sleep(IDLE_TIME) --wait 0.9 sec
  18. end --rinse, repeat
  19. end --rinse, repeat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement