pan7nikt

Untitled

Apr 11th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. mon = peripheral.wrap("left")
  2. function lineBreak()
  3. x, y = mon.getCursorPos()
  4. if y ~= 1 then
  5. y = y + 1
  6. end
  7. mon.setCursorPos(1, y)
  8. width, height = mon.getSize()
  9. mon.write("+" .. string.rep("-", width - 2) .. "+")
  10. end
  11. function printString(sString)
  12. x, y = mon.getCursorPos()
  13. y = y + 1
  14. mon.setCursorPos(1, y)
  15. mon.write(sString)
  16. end
  17. function printStringCentre(sString)
  18. x, y = mon.getCursorPos()
  19. y = y + 1
  20. mon.setCursorPos(1, y)
  21. width, height = mon.getSize()
  22. nStringCentre = math.floor(string.len(sString) / 2)
  23. nMonitorCentre = math.floor(width / 2)
  24. x = math.floor(nMonitorCentre - nStringCentre)
  25. mon.setCursorPos(x, y)
  26. mon.write(sString)
  27. end
  28. function printStringRight(sString)
  29. width, height = mon.getSize()
  30. x, y = mon.getCursorPos()
  31. y = y + 1
  32. x = math.ceil(width - string.len(sString))
  33. mon.setCursorPos(x, y)
  34. mon.write(sString)
  35. end
  36. function scrollText(tStrings, nRate)
  37. nRate = nRate or 5
  38. if nRate < 0 then
  39. error("rate must be positive")
  40. end
  41. local nSleep = 1 / nRate
  42.  
  43. width, height = mon.getSize()
  44. x, y = mon.getCursorPos()
  45. sText = ""
  46. for n = 1, #tStrings do
  47. sText = sText .. tostring(tStrings[n])
  48. sText = sText .. " | "
  49. end
  50. sString = "| "
  51. if width / string.len(sText) < 1 then
  52. nStringRepeat = 3
  53. else
  54. nStringRepeat = math.ceil(width / string.len(sText) * 3)
  55. end
  56. for n = 1, nStringRepeat do
  57. sString = sString .. sText
  58. end
  59. while true do
  60. for n = 1, string.len(sText) do
  61. sDisplay = string.sub(sString, n, n + width - 1)
  62. mon.clearLine()
  63. mon.setCursorPos(1, y)
  64. mon.write(sDisplay)
  65. sleep(nSleep)
  66. end
  67. end
  68. end
  69. mon.clear()
  70. mon.setCursorPos(1, 1)
  71. lineBreak()
  72. printStringCentre("|News Board|")
  73. lineBreak()
  74. printString("")
  75. lineBreak()
  76. tScrollText = {}
  77. tScrollText[1] = "BREAKING NEWS"
  78. tScrollText[2] = "It's not in the way that you hold me It's not in the way you say you care It's not in the way you've been treating my friends It's not in the way that you stayed till the end It's not in the way you look or the things that you say that you'll do Hold the line, love isn't always on time, oh oh oh Hold the line, love isn't always on time, oh oh oh It's not in the words that you told me, girl It's not in the way you say you're mine, ooh It's not in the way that you came back to me It's not in the way that your love set me free It's not in the way you look or the things that you say that you'll do Hold the line, love isn't always on time, oh oh oh Hold the line, love isn't always on time, oh oh oh It's not in the words that you told me It's not in the way you say you're mine, ooh It's not in the way that you came back to me It's not in the way that your love set me free It's not in the way you look or the things that you say that you'll do Hold the line, love isn't always on time, oh oh oh Hold the line, love isn't always on time (Love isn't always on time) Hold the line, love isn't always on time (love isn't always, love isn't always on time) Hold the line, love isn't always on time Love isn't always on time Love isn't always on time Love isn't always on time, oh oh oh"
  79. x, y = mon.getCursorPos()
  80. y = y - 1
  81. mon.setCursorPos(1, y)
  82. scrollText(tScrollText)
Add Comment
Please, Sign In to add comment