Tweaked clock-chime.lua to hopefully be more robust.
This commit is contained in:
parent
5b1150452b
commit
8e6768532c
1 changed files with 7 additions and 5 deletions
|
|
@ -10,12 +10,14 @@ function pulse ()
|
||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local timedelta = os.time("ingame") % 12
|
local timedelta = (os.time("ingame") % 12) * 60 -- all times in seconds
|
||||||
if timedelta < 0.2 then -- too strict?
|
local sleep_amt = ((12 * 60) - timedelta) / 2 -- cut the time in half?
|
||||||
|
if timedelta < 1 then
|
||||||
pulse()
|
pulse()
|
||||||
os.sleep(0.2) -- don't pulse more than once
|
os.sleep(1) -- don't pulse more than once
|
||||||
else
|
elseif sleep_amt > 1 then
|
||||||
local sleep_amt = 60 * (12 - timedelta) / 2 -- cut the time in half?
|
|
||||||
os.sleep(sleep_amt)
|
os.sleep(sleep_amt)
|
||||||
|
else
|
||||||
|
os.sleep(0.2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue