@name BuildHelper
@inputs 
@outputs 
@persist Alpha Color:vector Grab:entity
@trigger 
runOnTick(1)

Prop = owner():aimEntity()
Weapon = owner():weapon():type() == "weapon_physgun"
M1 = owner():keyAttack1()

if(changed(M1) & M1 & Weapon & Prop){
    Prop:propNotSolid(1)   
     
    Alpha = Prop:getAlpha()
    Color = Prop:getColor()
    
    Prop:setColor(vec(255,10,10))
    
    Grab = Prop
}

if(changed(M1) & !M1 & Weapon & Grab){
    Prop = Grab
    Grab = noentity()
    
    Prop:propFreeze(1)
    Prop:propNotSolid(0)  
    
    Prop:setColor(Color, Alpha)
    
    
    PosSnap = 11.8625 #Phx
    #PosSnap = 5.8 #Sprops
    AngSnap = 22.5
    
    Pos = Prop:pos() 
    Ang = Prop:angles()
    
    Pos = round(Pos / PosSnap) * PosSnap    
    Ang = round(Ang / AngSnap) * AngSnap
    
    Prop:setPos(Pos)
    Prop:setAng(Ang)
    
    Prop:soundPlay(1,0,"buttons/button17.wav")
}
