Advertisement
ZNZNCOOP

Crismas_P

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