Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap( "right" )
- function writeCentered (dy, text, device)
- local w,h = device.getSize()
- local x = math.floor((w - string.len(text)) / 2)+1
- local y = math.floor(h/2) + dy
- device.setCursorPos(x,y)
- device.clearLine()
- device.write(text)
- end
- function writeCenteredInLine (y, text, device)
- local w,h = device.getSize()
- local x = math.floor((w - string.len(text)) / 2)+1
- device.setCursorPos(x,y)
- device.clearLine()
- device.write(text)
- end
- function getTime()
- local time = os.time()
- return textutils.formatTime(time, false)
- end
- function adjustTextScale(device)
- device.setTextScale(1)
- local w,h = device.getSize()
- local scale = 1
- while w > 12 do
- scale = scale+1
- device.setTextScale(scale)
- w, h = device.getSize()
- end
- end
- adjustTextScale(monitor)
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- monitor.setBackgroundColor(colors.black)
- while true do
- writeCentered(1,getTime(),monitor)
- sleep(0.1)
- end
Add Comment
Please, Sign In to add comment