Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- @param pulse length in seconds
- local pulseLength = 0.5
- -- @param clock speed in seconds
- local clockSpeed = 2
- -- @param pulse direction
- local pulseSide = "right"
- local inputSide = "front"
- -- @param redstone signal to disable clock
- -- true = redstone turns on
- -- false = redstone turns off
- -- nil = ignore redstone
- local redstone = nil
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("Clock running, output " .. pulseSide .. "...")
- print(string.format("PULSE %.1fs / CLOCK %.1fs", pulseLength, clockSpeed))
- -- use redstone signal to determine if the clock is on or off
- while redstone ~= rs.getInput(inputSide) do
- rs.setOutput(pulseSide, true)
- sleep(pulseLength)
- rs.setOutput(pulseSide, false)
- sleep(clockSpeed - pulseLength)
- end
- -- if we dropped out of the clock loop, wait for redstone
- print("OFF (Waiting for redstone)")
- event = os.pullEvent("redstone")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement