meuced

vaisseaubashaut

Nov 14th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. m = peripheral.wrap("bottom")
  2.  
  3. m.setTextScale(0.5)
  4. x,y = m.getSize()
  5. print(x..":"..y)
  6.  
  7. iter = 0
  8. text = "<====8"
  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]["y"] = stars[k]["y"]-1
  26.     end
  27.     for i=1,10 do
  28.         toAdd = {}
  29.         toAdd["y"] = y
  30.         toAdd["x"] = math.random(1,x)
  31.         if math.random(1,100) > 90 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.lightGray)
  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"] > x 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"] = 1
  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
Add Comment
Please, Sign In to add comment