Advertisement
Guest User

startup

a guest
Nov 25th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. m = peripheral.wrap("back")
  2.  
  3. m.setTextScale(0.5)
  4. x,y = m.getSize()
  5. print(x..":"..y)
  6.  
  7. iter = 0
  8. text = {}
  9.  
  10. items = {}
  11. stars = {}
  12. starsNbr = 200
  13.  
  14. function registerStars()
  15.     stars = {}
  16.     for i=1,starsNbr do
  17.         toAdd = {}
  18.         toAdd["x"] = math.random(1,x)
  19.         toAdd["y"] = math.random(1,y)
  20.         table.insert(stars,toAdd)
  21.     end
  22. end
  23.  
  24. function forwardStars()
  25.     for k,v in pairs(stars) do
  26.         stars[k]["x"] = stars[k]["x"]+1
  27.     end
  28.     for i=1,10 do
  29.         toAdd = {}
  30.         toAdd["x"] = 1
  31.         toAdd["y"] = math.random(1,y)
  32.         if math.random(1,100) > 90 then table.insert(stars,toAdd) end
  33.     end
  34. end
  35.  
  36. function drawStars()
  37.     for k,v in pairs(stars) do
  38.         m.setCursorPos(v["x"],v["y"])
  39.         if math.random(1,100) > 70 then m.setTextColor(colors.lightGray) else m.setTextColor(colors.gray) end
  40.         m.write(".")
  41.     end
  42. end
  43.  
  44. function redraw()
  45.     m.clear()
  46.     m.setTextColor(colors.gray)
  47.     drawStars()
  48.     m.setTextColor(colors.green)
  49.  for k,v in ipairs(items) do
  50.      items[k]["x"] = v["x"]+1
  51.         m.setCursorPos(v["x"],v["y"])
  52.   randText = math.random(1,3)
  53.   if randText < 2 then
  54.     text = "Airelad"
  55.   elseif randText > 2 then
  56.     text = "wormboy9000"
  57.   else
  58.     text = "_Mush_"
  59.   end
  60.         m.write(text)
  61.         x,y = m.getSize()
  62.         if v["x"] > x then table.remove(items,k) end
  63.     end
  64. end
  65.  
  66. function addPlot()
  67.     h = math.random(1,y)
  68.     add = {}
  69.     add["x"] = 1
  70.     add["y"] = h
  71.     table.insert(items,add)
  72. end
  73.  
  74. registerStars()
  75. addPlot()
  76. while true do
  77.     iter = iter + 1
  78.     redraw()
  79.     os.sleep(0.5)
  80.     if iter % 14 == 0 then addPlot() end
  81.     if iter % 20 == 0 then forwardStars() end
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement