Advertisement
LDDestroier

WPath -- wavey path!

Oct 12th, 2017
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. -- Wavey Path
  2. -- Makes a wavey path to the right
  3.  
  4. local wpath = {}
  5.  
  6. wpath.cols = "e145d9ba26"
  7. wpath.bwcols = "087f78"
  8. wpath.waveLen = 3
  9. wpath.textScale = 2.5
  10. wpath.delay = 0.05
  11.  
  12. local rbow,bbow
  13. local sizePath = "size.lua"
  14.  
  15. if not peripheral.find("monitor") then
  16.     return
  17. end
  18.  
  19. local reset = function()
  20.     rbow,bbow = "",""
  21.     for a = 1,#wpath.cols do
  22.         rbow = rbow..wpath.cols:sub(a,a):rep(wpath.waveLen)
  23.     end
  24.     for a = 1,#wpath.bwcols do
  25.         bbow = bbow..wpath.bwcols:sub(a,a):rep(wpath.waveLen)
  26.     end
  27. end
  28. reset()
  29.  
  30. local mons = {peripheral.find("monitor")}
  31. local setscales = function()
  32.     for a = 1, #mons do
  33.         mons[a].setTextScale(wpath.textScale)
  34.     end
  35. end
  36.  
  37. local wrap = function(txt,amnt)
  38.     local output = {}
  39.     for a = 0, #txt-1 do
  40.         output[((a+amnt) % #txt)+1] = txt:sub(a+1,a+1)
  41.     end
  42.     return table.concat(output)
  43. end
  44.  
  45. local render = function(shift,mon)
  46.     local line
  47.     if not mon.getSize then return end
  48.     local scr_x,scr_y = mon.getSize()
  49.     scr_y = scr_y + (scr_y % 2)
  50.     bow = mon.isColor() and rbow or bbow
  51.     for y = 1, scr_y do
  52.         mon.setCursorPos(1,y)
  53.         line = bow:rep(scr_x):sub(1,scr_x)
  54.         local text = ("#"):rep(scr_x)
  55.         local txcol = wrap(line, -1*math.abs(y-scr_y/2)+shift-1)
  56.         local bgcol = wrap(line, -1*math.abs(y-scr_y/2)+shift)
  57.         mon.blit(text,txcol,bgcol)
  58.     end
  59. end
  60.  
  61. local DOITNOW = function(YOUFUCKINGTWAT)
  62.     local shift = 0
  63.     while true do
  64.         shift = (shift + 1)
  65.         mons = {peripheral.find("monitor")}
  66.         setscales()
  67.         for a = 1, #mons do
  68.             render(shift,mons[a])
  69.         end
  70.         sleep(wpath.delay)
  71.     end
  72. end
  73.  
  74. --parallel.waitForAny(checkForReset,DOITNOW)
  75. DOITNOW()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement