SHOW:
|
|
- or go back to the newest paste.
1 | - | -- @param pulse length in ticks |
1 | + | -- @param pulse length in seconds |
2 | local pulseLength = 5 | |
3 | ||
4 | - | -- @param clock speed in ticks |
4 | + | -- @param clock speed in seconds |
5 | local clockSpeed = 20 | |
6 | ||
7 | -- @param pulse direction | |
8 | - | local pulseSide = "down" |
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 |
18 | + | -- use redstone signal to determine if the clock is on or off |
19 | - | while redstone == nil or redstone == rs.getInput(inputSide) do |
19 | + | while redstone ~= rs.getInput(inputSide) do |
20 | - | rs.setOutput(pulseSide, true) |
20 | + | rs.setOutput(pulseSide, true) |
21 | - | sleep(pulseLength / 20) |
21 | + | sleep(pulseLength) |
22 | ||
23 | - | rs.setOutput(pulseSide, false) |
23 | + | rs.setOutput(pulseSide, false) |
24 | - | sleep((clockSpeed - pulseLength) / 20) |
24 | + | sleep(clockSpeed - pulseLength) |
25 | - | end |
25 | + | end |
26 | ||
27 | - | -- if we dropped out of the clock loop, wait for redstone |
27 | + | -- if we dropped out of the clock loop, wait for redstone |
28 | - | event = os.pullEvent("redstone") |
28 | + | event = os.pullEvent("redstone") |
29 | end |