time=30*60
term.clear()
monitor=peripheral.find("monitor")
cmd=peripheral.find("command")
x,y=term.getSize()
if monitor then
  monitor.clear()
  x2,y2=monitor.getSize()
  monitor.setTextScale(5)
end
 
function round(num)
  if num-math.floor(num)<.5 then
    return math.floor(num)
  else
    return math.ceil(num) --If it's already an integer, rounding it up does nothing anyways.
  end
end
 
for i=time,1,-1 do
 
  currentTime=""
  currentTime=currentTime..math.floor(i/60)..":"
  if i-60*math.floor(i/60)<10 then
    currentTime=currentTime.."0"
  end
  currentTime=currentTime..i-60*math.floor(i/60)
 
  if monitor then
    monitor.setCursorPos(round(x2/2)-round(#tostring(i)/2),round(y2/2))
    monitor.write("          ")
    monitor.setCursorPos(round(x2/2)-round(#tostring(i)/2),round(y2/2))
    monitor.write(currentTime)
  else
    term.setCursorPos(round(x/2)-round(#tostring(i)/2),round(y/2))
    io.write("          ")
    term.setCursorPos(round(x/2)-round(#tostring(i)/2),round(y/2))
    io.write(currentTime)
  end
 
  if cmd then
    cmd.setCommand("say "..currentTime)
    cmd.runCommand()
  end
 
  sleep(1)
end
