21 lines
555 B
Lua
21 lines
555 B
Lua
-- 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
|