@name chainsaw
@inputs 
@outputs 
@persist N
@trigger 

if (first()) {
    E = entity()
    
    Offset = 24

    for (I = 1, 4) {
        holoCreate(I)
        holoParent(I, E)
        holoModel(I, "models/sprops/mechanics/racks/rack_24t_s.mdl")
        holoScale(I, vec(0.05, 1, 1))
        holoMaterial(I, "models/props_c17/oil_drum001a")
        
        #models/props_c17/oil_drum001h
        
        if (I == 1 | I == 2) {
            holoPos(I, E:toWorld(vec((I == 2)*0.75 + Offset, 0, 1)))
            holoAng(I, E:toWorld(ang(0,90,0)))
        } else {
            holoPos(I, E:toWorld(vec((I == 4)*0.75 + Offset, 0, -1)))
            holoAng(I, E:toWorld(ang(180,90,0)))        
        }
    }
    
    for (I = 5, 8) {
        holoCreate(I)
        holoParent(I, E)
        holoModel(I, "models/sprops/mechanics/sgears/spur_12t_s.mdl")
        holoScale(I, vec(0.575, 0.575, 0.05))
        holoMaterial(I, "models/props_c17/oil_drum001a")
        
        if (I == 5 | I == 6) {
            holoPos(I, E:toWorld(vec(19 + Offset, 0, 0)))
            holoAng(I, E:toWorld(ang((I == 6)*15,0,90)))
        } else {
            holoPos(I, E:toWorld(vec(-18 + Offset, 0, 0)))
            holoAng(I, E:toWorld(ang((I == 8)*15,0,90)))        
        }
    }

}

interval(15)
N = !N

for (I = 1, 8) {
    holoAlpha(I, ((I % 2) == 0 ? N : !N)*255)
}
