diff --git a/clock-chime.lua b/clock-chime.lua new file mode 100644 index 0000000..3244ca1 --- /dev/null +++ b/clock-chime.lua @@ -0,0 +1,23 @@ +-- Program that sends a redstone pulse at noon and midnight + +-- the side of the computer to output the pulse +local SIDE = "right" + +function pulse () + rs.setOutput(true, SIDE) + os.sleep(0.05) -- maybe sleep for a tick? + rs.setOutput(false, SIDE) +end + +while true do + local timedelta = (os.time("ingame") % 12) * 60 -- all times in seconds + local sleep_amt = ((12 * 60) - timedelta) / 2 -- cut the time in half? + if timedelta < 1 then + pulse() + os.sleep(1) -- don't pulse more than once + elseif sleep_amt > 1 then + os.sleep(sleep_amt) + else + os.sleep(0.2) + end +end