cc-stuff/clock-chime.lua
2025-08-20 22:26:29 -04:00

21 lines
555 B
Lua

-- 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
if timedelta < 0.2 then -- too strict?
pulse()
os.sleep(0.2) -- don't pulse more than once
else
local sleep_amt = 60 * (12 - timedelta) / 2 -- cut the time in half?
os.sleep(sleep_amt)
end
end