Pushok

NewYearTree

Dec 30th, 2011
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.40 KB | None | 0 0
  1. @name NewYearTree
  2. @persist Tree:table Coef Balls:table HoloCount:normal
  3.  
  4. function void buildTree( ConesCoef:normal )
  5. {
  6.     HoloCount = 4
  7.        
  8.     Cone1 = table()
  9.     Cone2 = table()
  10.     Cone3 = table()
  11.    
  12.     Cylinder = table()
  13.    
  14.     Origin = entity():pos()
  15.    
  16.     Cone1["id", normal] = 1
  17.     Cone2["id", normal] = 2
  18.     Cone3["id", normal] = 3
  19.     Cylinder["id", normal] = 4
  20.    
  21.     Cone1["pos", vector] = Origin + vec( 0, 0, Coef * 5 * ConesCoef + Coef * 4)
  22.     Cone2["pos", vector] = Origin + vec( 0, 0, (Coef * 5 + Coef * 4) * ConesCoef + Coef * 4)
  23.     Cone3["pos", vector] = Origin + vec( 0, 0, (Coef * 5 + Coef * 4 + Coef * 3) * ConesCoef + Coef * 4)
  24.     Cylinder["pos", vector] = Origin + vec( 0, 0, Coef * 2 )
  25.    
  26.     Cone1["radius", normal] = Coef*5
  27.     Cone2["radius", normal] = Coef*4
  28.     Cone3["radius", normal] = Coef*3
  29.    
  30.     Cone1["heigth", normal] = Coef*5*2
  31.     Cone2["heigth", normal] = Coef*4*2
  32.     Cone3["heigth", normal] = Coef*3*2
  33.    
  34.     Cone1["color", vector] = vec( 0, 255, 0 )
  35.     Cone2["color", vector] = vec( 0, 255, 0 )
  36.     Cone3["color", vector] = vec( 0, 255, 0 )
  37.     Cylinder["color", vector] = vec( 102, 51, 0 )
  38.    
  39.     Cone1["model", string] = "cone"
  40.     Cone2["model", string] = "cone"
  41.     Cone3["model", string] = "cone"
  42.     Cylinder["model", string] = "cylinder"
  43.    
  44.     Cone1["size", vector] = vec( 5, 5, 5 )
  45.     Cone2["size", vector] = vec( 4, 4, 4 )
  46.     Cone3["size", vector] = vec( 3, 3 ,3 )
  47.     Cylinder["size", vector] = vec(1, 1, 2)
  48.    
  49.     Tree:pushTable( Cone1 )
  50.     Tree:pushTable( Cone2 )
  51.     Tree:pushTable( Cone3 )
  52.     Tree:pushTable( Cylinder )
  53.    
  54.     for( I = 1, Tree:count() )
  55.     {
  56.         Table = Tree[I, table]
  57.        
  58.         holoCreate( Table["id", normal], Table["pos", vector], Table["size", vector], ang( 0, 0, 0 ), Table["color", vector] )
  59.         holoModel( Table["id", normal], Table["model", string] )
  60.     }
  61. }
  62.  
  63. function void makeBalls( Radius:normal, Amount:normal, Size:normal, Axis:normal, Pos:vector )
  64. {
  65.     Since = HoloCount + 1
  66.    
  67.     if( Amount > 30 - HoloCount + 1 )
  68.     {
  69.         print( "You can't make more than 30 holos" )
  70.         return
  71.     }
  72.    
  73.     HoloCount += Amount + 1
  74.    
  75.     ConeBalls = table()
  76.    
  77.     Ax = Axis
  78.     C = Axis / Radius
  79.     Dec = Axis / Amount
  80.    
  81.    
  82.     for( I = Since, Amount + Since )
  83.     {
  84.         Ball = table()
  85.        
  86.         Ball["id", normal] = I
  87.         Ball["color", vector] = vec( 255, 0, 0 )
  88.         Ball["size", vector] = vec( 1, 1, 1 ) * Size
  89.         Ball["model", string] = "sphere"
  90.        
  91.         Value = 180 / floor( Amount / 3 ) * (I - Since + 1)
  92.        
  93.         Ball["pos", vector] = Pos + vec( Radius * cos( Value ), Radius * sin( Value ), Ax - Axis )
  94.        
  95.         Axis -= Dec
  96.         Radius = Axis / C
  97.        
  98.         holoCreate( Ball["id", normal], Ball["pos", vector], Ball["size", vector], ang( 0, 0, 0 ), Ball["color", vector] )
  99.         holoModel( Ball["id", normal], Ball["model", string] )
  100.        
  101.         ConeBalls:pushTable( Ball )
  102.     }
  103.    
  104.     Balls:pushTable( ConeBalls )
  105. }
  106.  
  107.  
  108.  
  109. if( first() )
  110. {
  111.     Coef = 6
  112.    
  113.     buildTree( 0.8 )
  114.    
  115.     BallSizeCoef = 0.2
  116.    
  117.     for( I = 1, 3 )
  118.     {
  119.         Info = Tree[I, table]
  120.         makeBalls( Info["radius", normal]+Coef*BallSizeCoef, 8, BallSizeCoef, Info["heigth", normal], Info["pos", vector] + vec( 0, 0, -Info["radius", normal] ) )
  121.     }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment