LDDestroier

Wipe animation (CC)

Nov 29th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- pastebin get fVWPp88e wipe
  2. local doWipe = function()
  3.     local scr_x, scr_y = term.getSize()
  4.     local cols = "f7"
  5.     local length = scr_x/2
  6.     local render = function(col1,col2,prog,forwards)
  7.         term.setCursorPos(1,1)
  8.         local screen = (col1:rep(prog)..col2:rep(length-prog)):rep(scr_x*scr_y):sub(1,(scr_x*scr_y))
  9.         local line
  10.         for a = forwards and 1 or scr_y, forwards and scr_y or 1, forwards and 1 or -1 do
  11.             line = screen:sub((a-1)*scr_x+1,a*scr_x)
  12.             term.setCursorPos(1,a)
  13.             term.blit(("L"):rep(#line),line,line)
  14.         end
  15.     end
  16.     local pos1 = 2
  17.     local pos2 = pos1 - 1
  18.     local forwards = true
  19.     local reverse = false
  20.     while true do
  21.         for a = reverse and length or 1, reverse and 1 or length, reverse and -1 or 1 do
  22.             render(cols:sub(pos1,pos1),cols:sub(pos2,pos2),a,forwards)
  23.             sleep(0.0)
  24.         end
  25.            forwards = not forwards
  26.         reverse = not reverse
  27.         pos1 = (pos1 + 1)
  28.         pos2 = (pos2 + 1)
  29.         if pos1 > #cols then pos1 = 1 end
  30.         if pos2 > #cols then pos2 = 1 end
  31.     end
  32. end
  33. local mon = peripheral.find("monitor")
  34. if mon then
  35.     term.redirect(mon)
  36.     mon.setTextScale(0.5)
  37. end
  38. doWipe()
Add Comment
Please, Sign In to add comment