Advertisement
Imgoodisher

matrix

Mar 9th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. term.setTextColor(colors.lime)
  2. local size={term.getSize()}
  3. local tPixels={}
  4. for x=1,size[1]-1 do
  5.     tPixels[x]={}
  6.     for y=1,size[2] do
  7.         tPixels[x][y]=' '
  8.     end
  9. end
  10. local function render()
  11.     term.clear()
  12.     term.setCursorPos(1,1)
  13.     for y=1,#tPixels[1] do
  14.         if y~=1 then
  15.             print('')
  16.         end
  17.         for x=1,#tPixels do
  18.             if tPixels[x][y+1] == ' ' and tPixels[x][y] ~= ' ' then
  19.                 term.setTextColor(colors.white)
  20.             else
  21.                 term.setTextColor(colors.lime)
  22.             end
  23.             write(tPixels[x][y])
  24.         end
  25.     end
  26. end
  27. local function cycle()
  28.     for x=1,#tPixels do
  29.         for y=#tPixels[x],2,-1 do
  30.             tPixels[x][y]=(tPixels[x][y-1]==' ' and ' ') or ((tPixels[x][y]~=' ' and tPixels[x][y]) or string.char(math.random(32,126)))
  31.         end
  32.         --[[for x=1,#tPixels do
  33.         local intC=nil
  34.         for y=2,5 do
  35.             if tPixels[x][y]==' ' then
  36.                 intC=true
  37.             end
  38.         end
  39.         if not intC then
  40.             tPixels[x][1]=' '
  41.         end
  42.         end]]
  43.     end
  44. end
  45. local function create()
  46.     tPixels[math.random(1,#tPixels)][1]=string.char(math.random(32,126))
  47.     tPixels[math.random(1,#tPixels)][1]=' '
  48.     tPixels[math.random(1,#tPixels)][1]=' '
  49. end
  50. local bRunning=true
  51. local i = 1
  52. while bRunning do
  53.     --i = (i + 1) % 3
  54.     cycle()
  55.     --if i == 1 then
  56.         create()
  57.     --end
  58.     render()
  59.     sleep(0.1)
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement