@name Door Alarm
@inputs 
@outputs User:entity 
@persist A [CornerPos1 CornerPos2]:vector 
@trigger 
interval(15)

if (first()) {
    entity():setAlpha(0)
    
    Scale = vec(3,2,5) * 12
    
    Door = holoCreate(1)
    
    holoScaleUnits(1,Scale)
    holoPos(1,entity():toWorld(vec(0,0,40)))
    holoAng(1,entity():angles())
    holoColor(1,vec(255,255,255),100)
    holoParent(1,entity())
    
    CornerPos1 = Scale / 2
    CornerPos2 = -CornerPos1
    
    CornerPos1 = Door:toWorld(CornerPos1)
    CornerPos2 = Door:toWorld(CornerPos2)
    
    CornerScale = vec() + 1
    
    holoCreate(2)
    holoPos(2,CornerPos1)
    holoScaleUnits(2,CornerScale)
    holoParent(2, Door)
    
    holoCreate(3)
    holoPos(3,CornerPos2)
    holoScaleUnits(3,CornerScale)
    holoParent(3, Door)
    
    for (I = 2,3) {holoColor(I,vec(),0)}
}

holoVisible(1,players(),0)
holoVisible(1,owner(),1)

findInBox(CornerPos1,CornerPos2)
findIncludeClass("player")
User = findClosest(holoEntity(1):pos())

if (User:isPlayer()) {A = 1} else {A = 0}

if (changed(A) & A) {
    soundPlay(1,0,"vo/taunts/demoman_taunts11.mp3")
    print(User:name()+" is at your door.")
    print("Holding "+User:weapon():type()+".")
} elseif (!A) {soundStop(1)}


