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")
- 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 hours >= 18 and hours <= 6 then
- if minutes >= 32 and hours == 18 then
- redstone.setOutput("top", true)
- else
- redstone.setOutput("top", true)
- end
- else
- redstone.setOutput("top", false)
- end
- end
Add Comment
Please, Sign In to add comment