SHOW:
|
|
- or go back to the newest paste.
| 1 | -- @param pulse length in seconds | |
| 2 | - | local pulseLength = 5 |
| 2 | + | local pulseLength = 0.5 |
| 3 | ||
| 4 | -- @param clock speed in seconds | |
| 5 | - | local clockSpeed = 20 |
| 5 | + | local clockSpeed = 2 |
| 6 | ||
| 7 | -- @param pulse direction | |
| 8 | local pulseSide = "right" | |
| 9 | local inputSide = "front" | |
| 10 | ||
| 11 | -- @param redstone signal to disable clock | |
| 12 | -- true = redstone turns on | |
| 13 | -- false = redstone turns off | |
| 14 | -- nil = ignore redstone | |
| 15 | local redstone = nil | |
| 16 | ||
| 17 | while true do | |
| 18 | -- use redstone signal to determine if the clock is on or off | |
| 19 | while redstone ~= rs.getInput(inputSide) do | |
| 20 | rs.setOutput(pulseSide, true) | |
| 21 | sleep(pulseLength) | |
| 22 | ||
| 23 | rs.setOutput(pulseSide, false) | |
| 24 | sleep(clockSpeed - pulseLength) | |
| 25 | end | |
| 26 | ||
| 27 | -- if we dropped out of the clock loop, wait for redstone | |
| 28 | event = os.pullEvent("redstone")
| |
| 29 | end |