Advertisement
CelticCoder

ComputerClock

Aug 7th, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.68 KB | None | 0 0
  1. -- Wrap the monitor
  2. local monitor = peripheral.wrap("left") -- Adjust the side as needed
  3.  
  4. -- Function to convert Minecraft time to a readable format
  5. function formatTime(minecraftTime)
  6.     local hours = math.floor(minecraftTime / 1000 + 6) % 24
  7.     local minutes = math.floor((minecraftTime % 1000) / 1000 * 60)
  8.     return string.format("%02d:%02d", hours, minutes)
  9. end
  10.  
  11. while true do
  12.     -- Get the current Minecraft time
  13.     local time = os.time()
  14.  
  15.     -- Clear the screen
  16.     monitor.clear()
  17.     monitor.setCursorPos(1, 1)
  18.  
  19.     -- Print the formatted time
  20.     monitor.write("Current Time: " .. formatTime(time))
  21.  
  22.     -- Wait for a second before updating
  23.     sleep(1)
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement