Advertisement
nagoL2015

Monitor Fade

Sep 4th, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. local monitor = peripheral.wrap("left")
  2. if not monitor then
  3.     error("No monitor...!")
  4. end
  5.  
  6. function clear(y)
  7.     monitor.setBackgroundColor(colours.black)
  8.     monitor.clear()
  9.     monitor.setCursorPos(1, y or 1)  
  10. end
  11.  
  12. local size = monitor.setTextScale
  13.  
  14. local cwrite = function(txt,y)
  15.     local sx,sy = (monitor or term).getSize()
  16.     local cx,cy = (monitor or term).getCursorPos()
  17.     monitor.setCursorPos((sx/2)-math.floor(#txt/2), y or cy)
  18.     return (monitor or term).write(txt)
  19. end
  20.  
  21. local fadeCwrite = function(txt,y,delay,noFadeOut)
  22.     delay = delay or 3
  23.     local pCol = monitor.getTextColor()
  24.     local cols = {
  25.         colors.black,
  26.         colors.gray,
  27.         colors.lightGray,
  28.         colors.white,
  29.     }
  30.     for a = 1, #cols do
  31.         monitor.setTextColor(cols[a])
  32.         cwrite(txt,y)
  33.         sleep(0.1)
  34.     end
  35.     if not noFadeOut then
  36.         sleep(delay)
  37.         for a = #cols, 1, -1 do
  38.             monitor.setTextColor(cols[a])
  39.             cwrite(txt,y)
  40.             sleep(0.1)
  41.         end
  42.     end
  43.     monitor.setTextColor(pCol)
  44. end
  45.  
  46. term.clear()
  47. term.setCursorPos(1,1)
  48. print("Displaying sign.")
  49. clear()
  50. while true do
  51. --    clear(1)
  52.     sleep(0.1)
  53. --    size(2)
  54. --    cwrite("Storage",1)
  55. --    cwrite("House",2)
  56.     fadeCwrite("Storage House",1,3,false)
  57. --    sleep(2)
  58. --    clear(2)
  59.     sleep(0.1)
  60. --    size(2)
  61. --    cwrite("Rent your own",1)
  62. --    cwrite("Storage Room",2)
  63. --    sleep(3)
  64.     fadeCwrite("Rent your own",1,0.5,true)
  65.     fadeCwrite(" storage room",2,3,false)
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement