Advertisement
LBPHacker

sisiftbVI for LeKiwiOriGinal

Sep 10th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. m = peripheral.wrap("left")
  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]["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) > 90 then table.insert(stars) 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.red)
  39.   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.lightGray)
  49.  for k,v in pairs(items) do
  50.   items[k]["x"] = v["x"]-1
  51.   m.setCurorPos(v["x"],v["y"])
  52.   m.write(text)
  53.   if v["x"] < 0 then table.remove(items,k) end
  54.  end
  55. end
  56.  
  57. function addPlot()
  58.  h = math.random(1,y)
  59.  add = {}
  60.  add["x"] = x
  61.  add["y"] = h
  62.  table.insert(items,add)
  63. end
  64.  
  65. registerStars()
  66. while true do
  67.  iter = iter + 1
  68.  redraw()
  69.  os.sleep(0.05)
  70.  if iter % 14 == 0 then addPlot() end
  71.  if iter % 20 == 0 then forwardStars() end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement