craniumkid22

Patterns

Mar 30th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. local x1 = 1
  2. local x2 = 51
  3. local y1 = 1
  4. local y2 = 19
  5. local xStep = 1
  6. local yStep = 1
  7.  
  8. local charList = {"|", "/", "-", "\\"}
  9.  
  10. local function ripple(rand)
  11.     local index = 1
  12.     while true do
  13.         local rTimer = os.startTimer(.05)
  14.         local events = {os.pullEvent()}
  15.         if events[1] == "timer" then
  16.             for w = x1, x2, xStep do
  17.                 index = rand and math.random(1, #charList) or (index + 1)
  18.                 if index > #charList and not rand then index = 1 end
  19.                 term.setBackgroundColor(2 ^ math.random(0, 15))
  20.                 for h = y1, y2, yStep do
  21.                     term.setCursorPos(w, h)
  22.                     write(charList[index])
  23.                 end
  24.             end
  25.         elseif events[1] == "mouse_click" or events[1] == "mouse_drag" then
  26.             if events[2] == 1 then
  27.                 x1 = events[3]
  28.                 y1 = events[4]
  29.             elseif events[2] == 2 then
  30.                 x2 = events[3]
  31.                 y2 = events[4]
  32.             end
  33.             term.setBackgroundColor(colors.black)
  34.             term.clear()
  35.         end
  36.         if x1 > x2 then xStep = -1 else xStep = 1 end
  37.         if y1 > y2 then yStep = -1 else yStep = 1 end
  38.     end
  39. end
  40.  
  41. ripple(false)
Advertisement
Add Comment
Please, Sign In to add comment