Advertisement
Dlog_M125

time

Jul 20th, 2024 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. -- Define the side where the monitor is connected
  2. local monitorSide = "right" -- Change this to the side where your monitor is connected
  3.  
  4. -- Function to initialize the monitor
  5. local function setupMonitor()
  6. local monitor = peripheral.wrap(monitorSide)
  7. monitor.setTextScale(1) -- Adjust text scale if necessary
  8. monitor.setBackgroundColor(colors.black)
  9. monitor.setTextColor(colors.white)
  10. monitor.clear()
  11. return monitor
  12. end
  13.  
  14. -- Function to update the time on the monitor
  15. local function updateTime(monitor)
  16. while true do
  17. local time = textutils.formatTime(os.time(), true)
  18. monitor.clear()
  19. monitor.setCursorPos(1, 1)
  20. monitor.write("Current Time: " .. time)
  21. sleep(1) -- Wait for 1 second before updating the time
  22. end
  23. end
  24.  
  25. -- Main execution
  26. local monitor = setupMonitor()
  27. updateTime(monitor)
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement