Program for managing a clock tower bell.

This commit is contained in:
erosenjo 2025-08-20 22:26:29 -04:00
parent 4006bd8175
commit 5b1150452b

21
clock-chime.lua Normal file
View file

@ -0,0 +1,21 @@
-- 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