Advertisement
King0fGamesYami

Advanced Monitor

Mar 17th, 2014
1,217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.72 KB | None | 0 0
  1. t = term
  2. t.sCP = t.setCursorPos
  3. t.w = t.write
  4. t.clear()
  5. t.sCP(1, 1)
  6. print("This program is provided by KingofGamesYami for personal use, please do not distribute.  If your program is not working, check that you are using the correct syntax.  If you use the scroll function, you must hold down control+t to stop the program.  Press any key to continue")
  7. os.pullEvent(key)
  8. sleep(0.1)
  9. t.clear()
  10. t.sCP(1, 1)
  11. t.w("Side: ") --side of your monitor
  12. local side = string.lower(read())
  13. if side == "top" or side == "right" or side == "left" or side == "back" or side == "bottom" or side == "front" then --check side is valid
  14.  --do nothing
  15. else
  16.  print("Invalid side!")
  17.  sleep(10)
  18.  os.shutdown()
  19. end
  20. m = peripheral.wrap(side)
  21. m.clear()
  22. m.setCursorPos(1, 1)
  23. t.sCP(1, 2)
  24. t.w("Text Color: ") --Color of text
  25. local input = string.lower(read())
  26. local tcolor
  27. if (colors[input] and type(colors[input]) == "number") or (colours[input] and type(colours[input]) == "number") then
  28.   tcolor = colors[input] or colours[input]
  29. elseif tonumber(input) then
  30.   tcolor = tonumber(input)
  31. else
  32.   print("Not a number or color!")
  33.   sleep(10)
  34.   os.shutdown()
  35. end
  36. m.setTextColor(tcolor)
  37. t.sCP(1, 3)
  38. t.w("Background Color: ")
  39. local input = string.lower(read())
  40. local bcolor
  41. if (colors[input] and type(colors[input]) == "number") or (colours[input] and type(colours[input]) == "number") then
  42.   bcolor = colors[input] or colours[input]
  43. elseif tonumber(input) then
  44.   bcolor = tonumber(input)
  45. else
  46.   print("Not a number or color!")
  47.   sleep(10)
  48.   os.shutdown()
  49. end
  50. m.setBackgroundColor(bcolor) --Set Background Color
  51. m.clear()
  52. t.sCP(1, 4)
  53. t.w("Text Size: ") --Size of Text (1 - 5)
  54. local size = tonumber(read())
  55. if tonumber(size) == nil then --is number?
  56.  print("Thats not a number!")
  57.  sleep(10)
  58.  os.shutdown()
  59. elseif size >= 0.5 and size <= 5 then --check size is valid
  60.  --do nothing
  61. else
  62.  print("Your size isn't within the limits... 0.5 - 5")
  63.  sleep(10)
  64.  os.shutdown()
  65. end
  66. m.setTextScale(size)
  67. t.sCP(1, 5)
  68. t.w("Text: ") --Text that will be printed
  69. local stuff = read()
  70. t.sCP(1, 6) --Scroll
  71. t.w("Would you like your text to scroll?: ")
  72. local scroll = string.lower(read())
  73. if scroll == "yes" then
  74.  t.sCP(1, 7)
  75.  t.w("Speed: ")
  76.  speed = tonumber(read())
  77.  local tlen = string.len(stuff)
  78.  local mwidth, mheight = m.getSize()
  79.  if mheight/2 == 0.5 then
  80.   mheight = 2
  81.  end
  82.  local tpos = mwidth
  83.  while true do --loop
  84.   if tpos == 0-tlen then --reset position
  85.    tpos = mwidth
  86.   end
  87.   m.clear()
  88.   m.setCursorPos(tpos, mheight/2)
  89.   m.write(stuff)
  90.   tpos = tpos-1
  91.   os.sleep(0.5/speed)
  92.  end
  93. elseif scroll == "no" then
  94.  sleep(0.1)
  95. else
  96.  print("Invalid answer, use yes or no")
  97.  sleep(10)
  98.  os.shutdown()
  99. end
  100. t.redirect(m)
  101. print(stuff)
  102. t.restore()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement