Advertisement
Rukerisu

Clock 3x2

Jun 8th, 2025 (edited)
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | Gaming | 0 0
  1. local monitor = peripheral.find("monitor")
  2. if not monitor then
  3.   print("Monitor not connected!")
  4.   return
  5. end
  6.  
  7. monitor.setBackgroundColor(colors.black)
  8. monitor.setTextScale(1.5)
  9. monitor.clear()
  10.  
  11.  
  12. local function writeLineCentered(y, text, color)
  13.   local w, _ = monitor.getSize()
  14.   local x = math.floor((w - #text) / 2) + 1
  15.   monitor.setCursorPos(x, y)
  16.   monitor.setTextColor(color)
  17.   monitor.write(text)
  18. end
  19.  
  20. while true do
  21.   monitor.clear()
  22.  
  23.  
  24.   local _, h = monitor.getSize()
  25.  
  26.  
  27.   local startY = math.floor((h - 4) / 2) + 1
  28.  
  29.  
  30.   local realTime = textutils.formatTime(os.time("local"), true)
  31.   local gameTime = textutils.formatTime(os.time(), true)
  32.  
  33.  
  34.   writeLineCentered(startY, "Real Time", colors.orange)
  35.   writeLineCentered(startY + 1, realTime, colors.green)
  36.  
  37.  
  38.   writeLineCentered(startY + 3, "Minecraft Time", colors.orange)
  39.   writeLineCentered(startY + 4, gameTime, colors.green)
  40.  
  41.   sleep(0.1)
  42. end
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement