CodeCrafter

clock

Feb 18th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. mon = peripheral.wrap("top") --connects to the monitor on top of the computer
  2. sec = 0 --declare variables
  3. min = 0
  4. uur = 0
  5.  
  6. mon.setTextScale(1.5) --set the text scale of the monitor to a 1.5 magnification
  7.  
  8. term.redirect(mon) --redirect the output ot the monitors
  9. while true do --main loop
  10. term.clear() --clear the screen
  11. term.setCursorPos(1,1) --set the cursor to the left upper corner
  12.  
  13. if sec==60 then --if 60 seconds have past add 1 to minutes and set seconds to 0
  14. min = min + 1 --adds 1 to minutes
  15. sec = 0
  16. end --ends if
  17.  
  18. sec = sec + 1 --counts the seconds
  19.  
  20. if min==60 then --if 60 minutes have past add 1 to uur(hours) and set minutes to 0
  21. uur = uur + 1 --adds 1 to uur(hours)
  22. min = 0
  23. end
  24. --prints everything
  25. print("time is: ")
  26. print(sec.." seconds")
  27. print(min.." minutes")
  28. print(uur.." hours")
  29. sleep(1) --sleeps for 1 second
  30. end
Add Comment
Please, Sign In to add comment