Program for managing a clock tower bell.
This commit is contained in:
parent
4006bd8175
commit
5b1150452b
1 changed files with 21 additions and 0 deletions
21
clock-chime.lua
Normal file
21
clock-chime.lua
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue