Advertisement
Derek1017

Text

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