ezra3131

sign

Nov 10th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. --[[made by ezra3131]]--
  2. local side = "right" --kant van monitor
  3. local tekst = "moving text program" --tekst om te laten zien
  4. local speed = 4 -- hoe hoger, hoe sneller
  5. local scale = 5 -- tekstgrootte
  6. local yPos = 1 -- plaats Y-as
  7.  
  8. ---------------------------------------------
  9.  
  10.  
  11. local m = peripheral.wrap(side)
  12. m.setTextScale(scale)
  13. local sizeX,sizeY = m.getSize()
  14. local xPos = sizeX
  15.  
  16. local printText = function()
  17. while true do
  18. m.clear()
  19. m.setCursorPos(xPos,yPos)
  20. m.write(tekst)
  21. if xPos < 1 - string.len(tekst) then
  22. xPos = sizeX
  23. else
  24. xPos = xPos - 1
  25. end
  26. os.sleep(1 / speed)
  27. end
  28. end
  29.  
  30. --clock program
  31. local time = http.get("http://www.timeapi.org/cet/now").readAll()
  32. time = string.sub(time, 12, 19)
  33.  
  34. local m = peripheral.wrap("top")
  35. m.setCursorPos(1,2)
  36.  
  37. local hours = time
  38. hours = tonumber(string.sub(hours, 1, 2))
  39. local minutes = time
  40. minutes = tonumber(string.sub(minutes, 4,5))
  41. local seconds = time
  42. seconds = tonumber(string.sub(seconds, 7,8))
  43.  
  44. local addHour = function()
  45. hours = hours + 1
  46. if hours >= 24 then
  47. hours = hours - 24
  48. end
  49. end
  50.  
  51. local addMinute = function()
  52. minutes = minutes + 1
  53. if minutes >= 60 then
  54. minutes = minutes - 60
  55. addHour()
  56. end
  57. end
  58.  
  59. local addSecond = function()
  60. seconds = seconds + 1
  61. if seconds >= 60 then
  62. seconds = seconds - 60
  63. addMinute()
  64. end
  65. end
  66.  
  67. local printTime = function()
  68. m.clear()
  69. if hours < 10 then
  70. m.setCursorPos(1,2)
  71. m.write(0)
  72. m.setCursorPos(2,2)
  73. m.write(hours)
  74. else
  75. m.setCursorPos(1,2)
  76. m.write(hours)
  77. end
  78. m.setCursorPos(3,2)
  79. m.write(":")
  80. if minutes < 10 then
  81. m.setCursorPos(4,2)
  82. m.write(0)
  83. m.setCursorPos(5,2)
  84. m.write(minutes)
  85. else
  86. m.setCursorPos(4,2)
  87. m.write(minutes)
  88. end
  89. m.setCursorPos(6,2)
  90. m.write(":")
  91. if seconds < 10 then
  92. m.setCursorPos(7,2)
  93. m.write(0)
  94. m.setCursorPos(8,2)
  95. m.write(seconds)
  96. else
  97. m.setCursorPos(7,2)
  98. m.write(seconds)
  99. end
  100. end
  101.  
  102. local printClock = function()
  103. while true do
  104. addSecond()
  105. printTime()
  106. os.sleep(1)
  107. end
  108. end
  109.  
  110. parallel.waitForAll(printText, printClock)
Advertisement
Add Comment
Please, Sign In to add comment