Pushok icon

NewYearTree

Pushok | PRO | 12/30/11 05:14:19 PM UTC | 0 ⭐ | 323 👁️ | Never ⏰ | []
Lua |

3.4 KB

|

None

|

0 👍

/

0 👎

@name NewYearTree
@persist Tree:table Coef Balls:table HoloCount:normal
 
function void buildTree( ConesCoef:normal )
{
    HoloCount = 4
       
    Cone1 = table()
    Cone2 = table()
    Cone3 = table()
    
    Cylinder = table()
    
    Origin = entity():pos()
    
    Cone1["id", normal] = 1
    Cone2["id", normal] = 2
    Cone3["id", normal] = 3
    Cylinder["id", normal] = 4
    
    Cone1["pos", vector] = Origin + vec( 0, 0, Coef * 5 * ConesCoef + Coef * 4)
    Cone2["pos", vector] = Origin + vec( 0, 0, (Coef * 5 + Coef * 4) * ConesCoef + Coef * 4)
    Cone3["pos", vector] = Origin + vec( 0, 0, (Coef * 5 + Coef * 4 + Coef * 3) * ConesCoef + Coef * 4)
    Cylinder["pos", vector] = Origin + vec( 0, 0, Coef * 2 )
    
    Cone1["radius", normal] = Coef*5
    Cone2["radius", normal] = Coef*4
    Cone3["radius", normal] = Coef*3
    
    Cone1["heigth", normal] = Coef*5*2
    Cone2["heigth", normal] = Coef*4*2
    Cone3["heigth", normal] = Coef*3*2
    
    Cone1["color", vector] = vec( 0, 255, 0 )
    Cone2["color", vector] = vec( 0, 255, 0 )
    Cone3["color", vector] = vec( 0, 255, 0 )
    Cylinder["color", vector] = vec( 102, 51, 0 )
    
    Cone1["model", string] = "cone"
    Cone2["model", string] = "cone"
    Cone3["model", string] = "cone"
    Cylinder["model", string] = "cylinder"
    
    Cone1["size", vector] = vec( 5, 5, 5 )
    Cone2["size", vector] = vec( 4, 4, 4 )
    Cone3["size", vector] = vec( 3, 3 ,3 )
    Cylinder["size", vector] = vec(1, 1, 2)
    
    Tree:pushTable( Cone1 )
    Tree:pushTable( Cone2 )
    Tree:pushTable( Cone3 )
    Tree:pushTable( Cylinder )
    
    for( I = 1, Tree:count() )
    {
        Table = Tree[I, table]
        
        holoCreate( Table["id", normal], Table["pos", vector], Table["size", vector], ang( 0, 0, 0 ), Table["color", vector] )
        holoModel( Table["id", normal], Table["model", string] )
    }
}
 
function void makeBalls( Radius:normal, Amount:normal, Size:normal, Axis:normal, Pos:vector )
{
    Since = HoloCount + 1
    
    if( Amount > 30 - HoloCount + 1 )
    {
        print( "You can't make more than 30 holos" )
        return
    }
    
    HoloCount += Amount + 1
    
    ConeBalls = table()
    
    Ax = Axis
    C = Axis / Radius
    Dec = Axis / Amount
    
    
    for( I = Since, Amount + Since )
    {
        Ball = table()
        
        Ball["id", normal] = I
        Ball["color", vector] = vec( 255, 0, 0 )
        Ball["size", vector] = vec( 1, 1, 1 ) * Size
        Ball["model", string] = "sphere"
        
        Value = 180 / floor( Amount / 3 ) * (I - Since + 1)
        
        Ball["pos", vector] = Pos + vec( Radius * cos( Value ), Radius * sin( Value ), Ax - Axis )
        
        Axis -= Dec
        Radius = Axis / C
        
        holoCreate( Ball["id", normal], Ball["pos", vector], Ball["size", vector], ang( 0, 0, 0 ), Ball["color", vector] )
        holoModel( Ball["id", normal], Ball["model", string] )
        
        ConeBalls:pushTable( Ball )
    }
    
    Balls:pushTable( ConeBalls )
}
 
 
 
if( first() )
{
    Coef = 6
    
    buildTree( 0.8 )
    
    BallSizeCoef = 0.2
    
    for( I = 1, 3 )
    {
        Info = Tree[I, table]
        makeBalls( Info["radius", normal]+Coef*BallSizeCoef, 8, BallSizeCoef, Info["heigth", normal], Info["pos", vector] + vec( 0, 0, -Info["radius", normal] ) )
    }
}

Comments