diff --git a/clock-chime.lua b/clock-chime.lua index 963dd18..3244ca1 100644 --- a/clock-chime.lua +++ b/clock-chime.lua @@ -10,12 +10,14 @@ function pulse () end while true do - local timedelta = os.time("ingame") % 12 - if timedelta < 0.2 then -- too strict? + 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(0.2) -- don't pulse more than once - else - local sleep_amt = 60 * (12 - timedelta) / 2 -- cut the time in half? + 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