Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local updateRate = 0.08
- local updateTimer = os.startTimer(updateRate)
- local offsetX,offsetY=0,0
- local autoCenter = false
- local monSide = "top"
- local monScale = nil
- local writeTerm = term
- if monSide then
- writeTerm = peripheral.wrap(monSide)
- if monScale then
- writeTerm.setTextScale(monScale)
- end
- end
- if autoCenter then
- local w = writeTerm.getSize()
- offsetX = math.ceil(w/2) - 4 - 1
- end
- while true do
- local ev, uTimer = os.pullEvent("timer")
- if updateTimer == uTimer then
- writeTerm.setCursorPos(1+offsetX,1+offsetY)
- writeTerm.clearLine()
- local time = os.time()
- local hours = math.floor(time)
- local minutes = math.floor( (time - hours)*60)
- local ampm = "am"
- if hours > 11 then
- ampm = "pm"
- if hours > 12 then
- hours = hours - 12
- end
- elseif hours == 0 then hours = 12
- end
- writeTerm.write(string.format("%s:%s",(hours<10 and "0"..hours or hours),(minutes<10 and "0"..minutes or minutes)).. " " .. ampm)
- updateTimer = os.startTimer(updateRate)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement