Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
commit
eeb2891e9c
1 changed files with 23 additions and 0 deletions
23
clock-chime.lua
Normal file
23
clock-chime.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
-- 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) * 60 -- all times in seconds
|
||||
local sleep_amt = ((12 * 60) - timedelta) / 2 -- cut the time in half?
|
||||
if timedelta < 1 then
|
||||
pulse()
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue