Pinkishu

randomScatter

Aug 11th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. randomScatter
  2. local tArgs = {...}
  3.  
  4. local x = tonumber(tArgs[1])
  5. local y = tonumber(tArgs[2])
  6. local screen = tArgs[3]
  7.  
  8. local width = 0
  9. for i=1,#screen,1 do
  10.     if string.len(screen[i]) > width then width = string.len(screen[i]) end
  11. end
  12.  
  13. local errChars = {"%","#","?","$","/","\\","="}
  14.  
  15. local nums = {}
  16. for cX=1,width,1 do
  17.     for cY = 1, #screen, 1 do
  18.         table.insert(nums,{cX,cY})
  19.     end
  20. end
  21. local c=0
  22. while #nums>0 do
  23.     local f = table.remove(nums,math.random(1,#nums))
  24.     term.setCursorPos(f[1]+x-1,f[2]+y-1)
  25.     term.write(errChars[math.random(1,#errChars)])
  26.     c=c+1
  27.     if c >= 3 then
  28.         c=0
  29.         sleep(.05)
  30.     end
  31. end
  32.  
  33.  
  34. local nums = {}
  35. for cX=1,width,1 do
  36.     for cY = 1, #screen, 1 do
  37.         table.insert(nums,{cX,cY})
  38.     end
  39. end
  40. c=0
  41. while #nums>0 do
  42.     local f = table.remove(nums,math.random(1,#nums))
  43.     term.setCursorPos(f[1]+x-1,f[2]+y-1)
  44.     if string.len(screen[f[2]]) < f[1] then
  45.         term.write(" ")
  46.     else
  47.         term.write(string.sub(screen[f[2]],f[1],f[1]))
  48.     end
  49.     c=c+1
  50.     if c>=3 then
  51.         sleep(.05)
  52.         c=0
  53.     end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment