Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This program can be used to create a digital clock on a monitor peripheral
- --The monitor must be placed to the right of the computer
- print("Running clock application. Hold ctrl + T to end.")
- --peripheral.call("right", "setTextScale", 2)
- local monitor = peripheral.wrap("right")
- local sirenSide = "top"
- local snooze = false
- function wipeLine(y)
- monitor.setCursorPos(1,y)
- monitor.write(" ")
- end
- function setSignal()
- monitor.write(" *ALARM*")
- if redstone.getOutput(sirenSide) then
- -- already set
- return
- else
- redstone.setOutput(sirenSide,true)
- end
- end
- function unsetSignal()
- if not redstone.getOutput(sirenSide) then
- -- already unset
- return
- else
- redstone.setOutput(sirenSide,false)
- end
- end
- while true do
- local decimalTime = os.time()
- local hours = math.floor(decimalTime)
- local minutes = math.floor((decimalTime - hours) * 100 * 0.6)
- local ampm
- if hours > 12 then
- hours = hours - 12
- ampm = "PM"
- else
- ampm = "AM"
- end
- monitor.clear()
- monitor.setCursorPos(1,1)
- if minutes < 10 then
- monitor.write(hours..":0"..minutes.." "..ampm)
- else
- monitor.write(hours..":"..minutes.." "..ampm)
- end
- sleep(.75)
- if decimalTime >= 18.541 or decimalTime <= 6.000 then
- setSignal()
- else
- unsetSignal()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement