Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. local function pulseCount(right)
  2. local pulses = 0
  3. local rsState = false
  4. local pulseTimeout = os.startTimer(5)
  5. while true do
  6. local e, p = os.pullEvent()
  7. --If the timer is up, break the loop.
  8. if e == "timer" and p == pulseTimeout then
  9. break
  10. elseif e == "redstone" then
  11. --If the redstone input on the specified side has changed, update the state variable.
  12. if rs.getInput(side) ~= rsState then
  13. pulseTimeout = os.startTimer(5)
  14. rsState = rs.getInput(side)
  15. --If the input just went low, the pulse just ended. Increment the counter.
  16. if rsState == false then
  17. pulses = pulses + 1
  18. end
  19. end
  20. end
  21. end
  22. return pulses
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement