Tectoon

[TFM] Matrix Anonimo

Jun 25th, 2015
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. ---
  2. -- Matrix Effect
  3. ---
  4.  
  5. matrix={
  6.     char={},
  7.     text={},
  8.     color={},
  9.     length={},
  10.     init=function(t)
  11.         for i=48,57 do
  12.             t.char[#t.char+1]=i
  13.         end
  14.         for i=65,90 do
  15.             t.char[#t.char+1]=i
  16.         end
  17.         for i=97,122 do
  18.             t.char[#t.char+1]=i
  19.         end
  20.         for x=1,53 do
  21.             t.length[x]=math.random(5,30)
  22.             for y=1,t.length[x] do
  23.                 t.text[x]=t.text[x] or ''
  24.                 t.text[x]=t.text[x]..string.char(table.random(t.char))..'\n'
  25.             end
  26.             t.length[x]=math.max(0,30-t.length[x])
  27.         end
  28.     end,
  29.     createTAs=function(t,name,init)
  30.         ui.addTextArea(1,'',name,-4e3,-4e3,8e3,8e3,1,0,1,1)
  31.         for i=1,#t.text do
  32.             if init then
  33.                 t.color[i]=string.format('<font color="#%x">',math.random(100,255)*256)
  34.             end
  35.             ui.addTextArea(1+i,t.color[i]..t.text[i],name,((i-1)*15)+3,0,nil,nil,0,0,0,1)
  36.         end
  37.     end}
  38. function eventLoop()
  39.     for i=1,#matrix.color do
  40.         if matrix.length[i]>1 then
  41.             matrix.text[i]=string.char(table.random(matrix.char))..'\n'..matrix.text[i]
  42.             matrix.length[i]=matrix.length[i]-1
  43.         elseif matrix.length[i]<0 then
  44.             matrix.text[i]=' \n'..matrix.text[i]
  45.             matrix.length[i]=matrix.length[i]+1
  46.         elseif matrix.length[i]==0 then
  47.             matrix.length[i]=math.random(5,30)
  48.         elseif matrix.length[i]==1 then
  49.             matrix.length[i]=-math.random(5,15)
  50.         end
  51.         if #matrix.text[i]>30 then
  52.             matrix.text[i]=matrix.text[i]:sub(1,60)
  53.         end
  54.         ui.updateTextArea(i+1,matrix.color[i]..matrix.text[i])
  55.     end
  56. end
  57. function eventNewPlayer(name)
  58.     matrix:createTAs(name)
  59. end
  60. function table.random(t)
  61.     return t[math.random(#t)]
  62. end
  63. matrix:init()
  64. matrix:createTAs(nil,true)
Advertisement
Add Comment
Please, Sign In to add comment