Florian86

Showing Clock on Monitor

Jan 15th, 2022 (edited)
702
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. monitor = peripheral.wrap("right") -- Moved the initialization out of the loop
  2. monitor.setTextScale(1)
  3.  
  4. repeat  
  5.   term.clear()  -- Moved to start of loop to handle case where cursor is somewhere weird to begin with
  6.   term.setCursorPos( 1, 1 )
  7.   local nTime = os.time()
  8.   -- print( "The time is "..textutils.formatTime( nTime, false ) )
  9.   local towritedown = ""..textutils.formatTime( nTime, false ).." "
  10.   print( towritedown )
  11.  
  12.   monitor.clear()
  13.   monitor.setCursorPos( 1, 1 )
  14.   monitor.write(towritedown)
  15.  
  16.   -- if nTime < 18 and nTime > 6 then
  17.   --     print("Have a good day!")
  18.   -- else
  19.   --      print("Have a good night!")
  20.   -- end
  21.  
  22.   sleep(1)
  23.  
  24. until nil
  25.  
  26.  
RAW Paste Data