SHOW:
|
|
- or go back to the newest paste.
1 | -- @param pulse length in seconds | |
2 | local pulseLength = 0.5 | |
3 | ||
4 | -- @param clock speed in seconds | |
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 | term.clear() | |
19 | term.setCursorPos(1,1) | |
20 | - | print("T " .. pulseLength .. " / C " .. clockSpeed) |
20 | + | |
21 | print("Clock running, output " .. pulseSide .. "...") | |
22 | print(string.format("PULSE %.1fs / CLOCK %.1fs", pulseLength, clockSpeed)) | |
23 | ||
24 | -- use redstone signal to determine if the clock is on or off | |
25 | while redstone ~= rs.getInput(inputSide) do | |
26 | rs.setOutput(pulseSide, true) | |
27 | sleep(pulseLength) | |
28 | ||
29 | rs.setOutput(pulseSide, false) | |
30 | sleep(clockSpeed - pulseLength) | |
31 | end | |
32 | - | print("") |
32 | + | |
33 | -- if we dropped out of the clock loop, wait for redstone | |
34 | print("OFF (Waiting for redstone)") | |
35 | event = os.pullEvent("redstone") | |
36 | end |