Rolcam

Computercraft Multi-purpose Ticker Sign V2

Jul 20th, 2020 (edited)
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. -- Auto detects monitor
  2. tSides = {"left","right","bottom","top","front","back"}
  3.  
  4. for i = 1, #tSides do
  5.   monitor = peripheral.wrap(tSides[i])
  6.   if monitor then
  7.         side = tSides[i]
  8.         break
  9.   end
  10. end
  11.  
  12. mon = peripheral.wrap(side)
  13.  
  14. -- number of signs
  15. signs = 3
  16. --color variable
  17. c = 0
  18.  
  19. -- Randomizes text color
  20. function raincol()
  21.     c = math.random(1,15)
  22.  
  23.     --Converts the random number into a valid color value
  24.     if c == 3 then
  25.         c = 4
  26.     elseif c == 4 then
  27.         c = 8
  28.     elseif c == 5 then
  29.         c = 16
  30.     elseif c == 6 then
  31.         c = 32
  32.     elseif c == 7 then
  33.         c = 64
  34.     elseif c == 8 then
  35.         c = 128
  36.     elseif c == 9 then
  37.         c = 256
  38.     elseif c == 10 then
  39.         c = 512
  40.     elseif c == 11 then
  41.         c = 1024
  42.     elseif c == 12 then
  43.         c = 2048
  44.     elseif c == 13 then
  45.         c = 4096
  46.     elseif c == 14 then
  47.         c = 8192
  48.     elseif c == 15 then
  49.         c = 16384
  50.     end
  51.     mon.setTextColor(c)
  52. end
  53.  
  54. -- Beginning position of scrolling text
  55. local pos = 18
  56. pos2 = 24
  57.  
  58. -- Initial Setup
  59.  
  60. mon.clear()
  61. raincol()
  62. mon.setTextScale(5)
  63. sign = 1
  64.  
  65. -- Main Program
  66. while true do
  67.     -- Sign Toggle and reset
  68.     if pos == -pos2 then
  69.         pos = 18
  70.         raincol()
  71.         if sign == signs then
  72.             sign = 1
  73.         else
  74.             sign = sign + 1
  75.         end
  76.     end
  77.  
  78.     --clears monitor and adjusts cursor position
  79.     mon.clear()
  80.     mon.setCursorPos(pos,1)
  81.  
  82.     --Displays Signs
  83.     if sign == 1 then
  84.         mon.setTextColor(colors.orange)
  85.         pos2 = 24
  86.         mon.write("Welcome to Rolcam's Shop")
  87.     elseif sign == 2 then
  88.         pos2 = 50
  89.         mon.write("Eat at Crazy Betty's Canned Bread Emporium!!!")
  90.     elseif sign == 3 then
  91.         raincol()
  92.         pos2 = 15
  93.         mon.write("Your Ad Here")
  94.     end
  95.  
  96.     --Adjusts Cursor position variable
  97.     pos = pos - 1
  98.  
  99.     --Prevents overflow errors (Keep this)
  100.     os.sleep(0.1)
  101.  
  102. end
Add Comment
Please, Sign In to add comment