-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmatrix.lua
More file actions
64 lines (63 loc) · 1.49 KB
/
matrix.lua
File metadata and controls
64 lines (63 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
-- Matrix Effect
---
matrix={
char={},
text={},
color={},
length={},
init=function(t)
for i=48,57 do
t.char[#t.char+1]=i
end
for i=65,90 do
t.char[#t.char+1]=i
end
for i=97,122 do
t.char[#t.char+1]=i
end
for x=1,53 do
t.length[x]=math.random(5,30)
for y=1,t.length[x] do
t.text[x]=t.text[x] or ''
t.text[x]=t.text[x]..string.char(table.random(t.char))..'\n'
end
t.length[x]=math.max(0,30-t.length[x])
end
end,
createTAs=function(t,name,init)
ui.addTextArea(1,'',name,-4e3,-4e3,8e3,8e3,1,0,1,1)
for i=1,#t.text do
if init then
t.color[i]=string.format('<font color="#%x">',math.random(100,255)*256)
end
ui.addTextArea(1+i,t.color[i]..t.text[i],name,((i-1)*15)+3,0,nil,nil,0,0,0,1)
end
end}
function eventLoop()
for i=1,#matrix.color do
if matrix.length[i]>1 then
matrix.text[i]=string.char(table.random(matrix.char))..'\n'..matrix.text[i]
matrix.length[i]=matrix.length[i]-1
elseif matrix.length[i]<0 then
matrix.text[i]=' \n'..matrix.text[i]
matrix.length[i]=matrix.length[i]+1
elseif matrix.length[i]==0 then
matrix.length[i]=math.random(5,30)
elseif matrix.length[i]==1 then
matrix.length[i]=-math.random(5,15)
end
if #matrix.text[i]>30 then
matrix.text[i]=matrix.text[i]:sub(1,60)
end
ui.updateTextArea(i+1,matrix.color[i]..matrix.text[i])
end
end
function eventNewPlayer(name)
matrix:createTAs(name)
end
function table.random(t)
return t[math.random(#t)]
end
matrix:init()
matrix:createTAs(nil,true)