@name DoorV2
@inputs Door:entity 
@outputs 
@persist I 
@trigger 
runOnTick(1)

findInSphere(Door:pos(),100)
findIncludeClass("player")
Target = findResult(1)

if (first()) {
    holoCreate(1)
    holoPos(1,Door:pos()+vec(0,-25,0))
    holoAlpha(1,0)
    
    holoCreate(2)
    holoPos(2,Door:pos()+vec(0,25,0))
    holoParent(2,Door)
    holoAlpha(2,0)
    
    Door:parentTo(holoEntity(1))
}

if(Target:aimEntity() == Door & changed(Target:keyUse()) & Target:keyUse() & I<1){
    holoAng(1,Door:toWorld(ang(0,90,0)))
    Door:soundPlay("Open",0,"doors/handle_pushbar_open1.wav")
    Door:setAng(holoEntity(1):angles())
    noCollideAll(Door,1)
    Name = find():name()
    printColor(vec(255,105,0),+Name,vec(0,255,255),"  has opened the front door.")
    I++
    timer("close",5000)
}

if(clk("close")){
    holoAng(1,ang(0,0,0))
    Door:soundPlay("Close",0,"doors/metal_stop1.wav")
    Door:setAng(holoEntity(1):angles())  
    noCollideAll(Door,0)
    I=0
}
