Advertisement
FakoTheGreat

Sign Script

Jul 14th, 2014
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. local monitorConnection = "top"
  2. local textScale = 5
  3. local lines = {"The Scenic", "Route"}
  4. local delay = 2
  5. local useColor = true
  6.  
  7. --used internally.
  8. monitor = nil
  9. local lColor = 1
  10. local nColor = 1
  11. local x = 1
  12. local y = 1
  13.  
  14. local function centerText(cString)
  15.   local offset = 1
  16.  
  17.   if string.len(cString) < x then
  18.     offset = math.floor((x - string.len(cString)) / 2) + 1
  19.   else
  20.     offset = 1
  21.   end
  22.   return offset
  23. end
  24.  
  25. local function getColor()
  26.   if monitor.isColor() then
  27.     while lColor == nColor do
  28.       nColor = math.random(1,15)
  29.     end
  30.  
  31.     lColor = nColor
  32.     monitor.setTextColor(nColor)
  33.   end
  34. end
  35.  
  36. print("Checking for Monitor.")
  37. while monitor == nil do
  38.   monitor = peripheral.wrap(monitorConnection)
  39.   os.sleep(1)
  40. end
  41.  
  42. print("Monitor Found, Running Program.")
  43.  
  44. monitor.setTextScale(textScale)
  45. x, y = monitor.getSize()
  46.  
  47. while true do
  48.   monitor.clear()
  49.   if useColor == true then
  50.     getColor()
  51.   end
  52.   for k,v in ipairs(lines) do
  53.     if k <= y then
  54.       monitor.setCursorPos(centerText(v),k)
  55.       monitor.write(v)
  56.     end
  57.   end
  58.   os.sleep(delay)
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement