ravneravn

rednet timer2

Apr 27th, 2013
40
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- monitor should be 4 high and 6 wide
  2. -- remember to check modem side and receiver ID
  3.  
  4. s = 0
  5. m = 0
  6. h = 0
  7. x = 0
  8. z = 0
  9.  
  10. function sendTime()
  11. zero = "0"
  12. second = tostring(s)
  13. minute = tostring(m)
  14. hour = tostring(h)
  15.  
  16. if s<10 then
  17. sendSec = zero..second
  18. else sendSec = second
  19. end
  20.  
  21. if m<10 then
  22. sendMin = zero..minute
  23. else sendMin = minute
  24. end
  25.  
  26. if h<10 then
  27. sendHour = zero..hour
  28. else sendHour = hour
  29. end
  30.  
  31. rednet.open("right")
  32. time = sendHour..":"..sendMin..":"..sendSec
  33. rednet.send(69, tostring(time))
  34. end
  35.  
  36. print("Runnnig")
  37. while true do
  38. mon = peripheral.wrap("back")
  39. mon.clear()
  40. mon.setTextScale(5)
  41. mon.setCursorPos(2,3)
  42.  
  43.  
  44. mon.setCursorPos(1,1)
  45. mon.setTextScale(5)
  46. mon.write("Time Elapsed")
  47.  
  48. mon.setCursorPos(2,3)
  49.  
  50. if s<10 then
  51. s = ("0" .. s)
  52. end
  53.  
  54. if m<10 then
  55. mon.write(" 0" .. h .. ":" .. "0" .. m .. ":" .. s)
  56. else
  57. mon.write(" 0" .. h .. ":" .. m .. ":" .. s)
  58. end
  59.  
  60.  
  61. s = (s+1)
  62. sleep(1)
  63. sendTime()
  64. if s>59 then
  65. s = 0
  66. m = (m+1)
  67. end
  68. if m>59 then
  69. m = 0
  70. h = (h+1)
  71. end
  72. end
RAW Paste Data