Advertisement
rithrin

Untitled

Aug 3rd, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. mon = peripheral.wrap("back")
  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.  
  12.  
  13. function printString(sString)
  14. x, y = mon.getCursorPos()
  15. y = y + 1
  16. mon.setCursorPos(1, y)
  17. mon.write(sString)
  18. end
  19. function printStringCentre(sString)
  20. x, y = mon.getCursorPos()
  21. y = y + 1
  22. mon.setCursorPos(1, y)
  23. width, height = mon.getSize()
  24. nStringCentre = math.floor(string.len(sString) / 2)
  25. nMonitorCentre = math.floor(width / 2)
  26. x = math.floor(nMonitorCentre - nStringCentre)
  27. mon.setCursorPos(x, y)
  28. mon.write(sString)
  29. end
  30. function printStringRight(sString)
  31. width, height = mon.getSize()
  32. x, y = mon.getCursorPos()
  33. y = y + 1
  34. x = math.ceil(width - string.len(sString))
  35. mon.setCursorPos(x, y)
  36. mon.write(sString)
  37. end
  38. function scrollText(tStrings, nRate)
  39. nRate = nRate or 5
  40. if nRate < 0 then
  41. error("rate must be positive")
  42. end
  43. local nSleep = 1 / nRate
  44.  
  45. width, height = mon.getSize()
  46. x, y = mon.getCursorPos()
  47. sText = ""
  48. for n = 1, #tStrings do
  49. sText = sText .. tostring(tStrings[n])
  50. sText = sText .. " | "
  51. end
  52. sString = "| "
  53. if width / string.len(sText) < 1 then
  54. nStringRepeat = 3
  55. else
  56. nStringRepeat = math.ceil(width / string.len(sText) * 3)
  57. end
  58. for n = 1, nStringRepeat do
  59. sString = sString .. sText
  60. end
  61. while true do
  62. for n = 1, string.len(sText) do
  63. sDisplay = string.sub(sString, n, n + width - 1)
  64. mon.clearLine()
  65. mon.setCursorPos(1, y)
  66. mon.write(sDisplay)
  67. sleep(nSleep)
  68. end
  69. end
  70. end
  71. mon.clear()
  72. mon.setCursorPos(1, 1)
  73. lineBreak()
  74. printStringCentre("|!!!ITEM WARNING!!!|")
  75. lineBreak()
  76. printString("")
  77. lineBreak()
  78. tScrollText = {}
  79. tScrollText[1] = "The following items are ALLOWED in the park."
  80. tScrollText[2] = "-IC2 Credits ALL KINDS"
  81. tScrollText[3] = "-Bread"
  82. tScrollText[4] = "-Long Fall Boots"
  83. tScrollText[5] = "--Cookies"
  84. x, y = mon.getCursorPos()
  85. y = y - 1
  86. mon.setCursorPos(1, y)
  87. scrollText(tScrollText)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement