Advertisement
HPWebcamAble

[CC][1.1] Scrolling Text (On CC Monitor)

Oct 25th, 2014
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. --[[
  2. Coded by HPWebcamAble
  3.  
  4. **********
  5. Description
  6. **********
  7. This program creates scrolling text on an advanced monitor
  8. It may be glitchy on slow servers because of the way Minecraft works
  9. *Change options below to configure*
  10.  
  11.  
  12. **********
  13. Program Version History
  14. **********
  15. |1.1| <-- This program
  16. Date: October 25, 2014
  17.   Changes:
  18.   -Cleaned up the code
  19.  
  20. |1.0 (Release)|
  21. Date: Unknown
  22.  
  23.  
  24. **********
  25. Options
  26. **********
  27. Make sure not to change any characters except text
  28. ]]
  29. --Set the side of the monitor
  30. local monitorSide = "left"
  31.  
  32. --Set the text to display
  33. local text = "This text is scrolling!"
  34.  
  35. --The time between text movement
  36. --Its usually best to leave this alone
  37. local sleepTime = 0.15
  38.  
  39. --The size of the text on the the monitor (1-5, decimals ok)
  40. local textScale = 2
  41.  
  42. --Background Color, must be 'colors.<color>'
  43. local bColor = colors.black
  44.  
  45. --Text Color
  46. local tColor = colors.white
  47.  
  48. --The height of the text (Y position)
  49. local ypos = 1
  50.  
  51. --[[
  52. *********
  53. Program
  54. **********
  55. ]]
  56. local textLen = string.len(text)
  57. local m = peripheral.wrap(monitorSide)
  58. m.setBackgroundColor(bColor)
  59. m.setTextColor(tColor)
  60. m.clear()
  61. mw,mh = m.getSize()
  62. local maxPos = mw+textLen/2
  63. m.setTextScale(textScale)
  64. pos = maxPos
  65. posMin = -textLen
  66. print("Text is scrolling...")
  67. print("Use ctrl+t to stop the program")
  68.  
  69. while true do
  70.   if pos < posMin then
  71.     pos = maxPos
  72.   end
  73.   m.clear()
  74.   m.setCursorPos(pos,ypos)
  75.   m.write(text)
  76.   pos = pos - 1
  77.   sleep(sleepTime)
  78. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement