Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("left")
- m.setTextScale(0.5)
- x,y = m.getSize()
- print(x..":"..y)
- iter = 0
- text = "<====8"
- items = {}
- stars = {}
- starsNbr = 150
- function registerStars()
- stars = {}
- for i=1,starsNbr do
- toAdd = {}
- toAdd["x"] = math.random(1,x)
- toAdd["y"] = math.random(1,y)
- table.insert(stars,toAdd)
- end
- end
- function forwardStars()
- for k,v in pairs(stars) do
- stars[k]["x"] = stars[k]["x"]-1
- end
- for i=1,10 do
- toAdd = {}
- toAdd["x"] = x
- toAdd["y"] = math.random(1,y)
- if math.random(1,100) > 90 then table.insert(stars) end
- end
- end
- function drawStars()
- for k,v in pairs(stars) do
- m.setCursorPos(v["x"],v["y"])
- if math.random(1,100) > 70 then m.setTextColor(colors.red)
- end
- m.write(".")
- end
- end
- function redraw()
- m.clear()
- m.setTextColor(colors.gray)
- drawStars()
- m.setTextColor(colors.lightGray)
- for k,v in pairs(items) do
- items[k]["x"] = v["x"]-1
- m.setCurorPos(v["x"],v["y"])
- m.write(text)
- if v["x"] < 0 then table.remove(items,k) end
- end
- end
- function addPlot()
- h = math.random(1,y)
- add = {}
- add["x"] = x
- add["y"] = h
- table.insert(items,add)
- end
- registerStars()
- while true do
- iter = iter + 1
- redraw()
- os.sleep(0.05)
- if iter % 14 == 0 then addPlot() end
- if iter % 20 == 0 then forwardStars() end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement