View difference between Paste ID: KN4pBkKH and d1ECnJR3
SHOW: | | - or go back to the newest paste.
1
m = peripheral.wrap("monitor_4")
2
m.setBackgroundColor(colors.black)
3
m.setTextScale(0.5)
4
x,y = m.getSize()
5
print(x..":"..y)
6
7
iter = 0
8
text = "(==<<=("
9
items = {}
10
stars = {}
11
starsNbr = 150
12
13
function registerStars()
14
	stars = {}
15
	for i=1,starsNbr do
16
		toAdd = {}
17
		toAdd["x"] = math.random(1,x)
18
		toAdd["y"] = math.random(1,y)
19
		table.insert(stars, toAdd)
20
	end
21
end
22
23
function forwardStars()
24
	for k,v in pairs(stars) do
25
		stars[k]["x"] = stars[k]["x"]-1
26
	end
27
	for i=1,10 do
28
		toAdd = {}
29
		toAdd["x"] = x
30
		toAdd["y"] = math.random(1,y)
31
		if math.random(1,100) > 80 then table.insert(stars, toAdd) end
32
	end
33
end
34
35
function drawStars()
36
	for k,v in pairs(stars) do
37
		m.setCursorPos(v["x"],v["y"])
38
		if math.random(1,100) > 70 then m.setTextColor(colors.gray) end
39
		m.write(".")
40
	end
41
end
42
43
function redraw()
44
	m.clear()
45
	m.setTextColor(colors.gray)
46
	drawStars()
47
	m.setTextColor(colors.red)
48
	for k,v in pairs(items) do
49
		items[k]["x"] = v["x"]-1
50
		m.setCursorPos(v["x"],v["y"])
51
		m.write(text)
52
		if v["x"] < 0 then table.remove(items,k) end
53
	end
54
end
55
56
function addPlot()
57
	h = math.random(1,y)
58
	add = {}
59
	add["x"] = x
60
	add["y"] = h
61
	table.insert(items,add)
62
end
63
64
registerStars()
65
while true do
66
	iter = iter + 1
67
	redraw()
68
	os.sleep(0.05)
69
	if iter % 14 == 0 then addPlot() end
70
	if iter % 20 == 0 then forwardStars() end
71
end