Advertisement
ZNZNCOOP

11

Jan 24th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. --m= peripheral.wrap('left')
  2. --term.redirect(m)
  3. term.setBackgroundColor(8)
  4. function addnow(x,y,colorr)
  5.    for i=1,#snow do
  6.       if (snow[i]['x'] == x and snow[i]['y'] == y) then
  7.          return
  8.       end
  9.    end
  10.    snow[#snow+1]= {}
  11.    snow[#snow]['x']= x
  12.    snow[#snow]['y']= 1
  13.    if (colorr == nil) then snow[#snow]['color']= randomColor() else snow[#snow]['color']= colorr end
  14. end
  15.  
  16. function snowupdate()
  17.    for i=#snow,1,-1 do
  18.       if (snow[i]['y'] > Y) then  table.remove(snow,i) end
  19.    end
  20.    for i=1,#snow do
  21.       q= math.random(1,5)
  22.       if (q == 3) then snow[i]['y']= snow[i]['y']+1 end
  23.       q= math.random(1,10)
  24.       if (q == 5) then qq= math.random(1,5) if (qq == 3) then snow[i]['x']= snow[i]['x']+1 else snow[i]['x']= snow[i]['x']-1 end end
  25.       q= math.random(1,20)
  26.       if (q == 5) then snow[i]['color']= randomColor() end
  27.    end
  28. end
  29.  
  30. function draw()
  31.    term.clear()
  32.    q= math.random(1,4000)
  33.    if (q == 1) then term.setBackgroundColor(randomColor()) end
  34.    for i=1,#snow do
  35.       term.setCursorPos(snow[i]['x'],snow[i]['y'])
  36.       term.setTextColor(snow[i]['color'])
  37.       write('X')
  38.    end
  39. end
  40.  
  41. function randomColor()
  42.    x= math.random(1,#color)
  43.    return x
  44. end
  45. color= {}
  46. for k,v in pairs(colors) do
  47.    color[#color+1]= v
  48. end
  49. snow= {}
  50. X,Y= term.getSize()
  51. while true do
  52.    x= math.random(1,X)
  53.    addnow(x,1)
  54.    draw()
  55.    snowupdate()
  56.    sleep(0)
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement