@name Smart Opener
@inputs 
@outputs Door
@persist P:array Distance:array A:array Target:entity D Z
@trigger

runOnTick(1)
#Distance
D = 60
#
S = owner():lastSaid():explode(" ")
if(S[1,string]=="!add" & chatClk(owner())){
    TP = findPlayerByName(S[2,string])
    if(TP:isPlayer()){
        Target = TP
        P:pushEntity(TP)
           }
   
}
if(S[1,string]=="!remove"& chatClk(owner())){
    TP = findPlayerByName(S[2,string])
    if(TP:isPlayer()){
        while(Z < 20){
        if(TP == P[Z,entity])
        {
        P:remove(Z)
        }
        Z++
}
}
Z = 0
}
Distance1 = round(((entity():pos() - P[1,entity]:pos()):length()))
Distance2 = round(((entity():pos() - P[2,entity]:pos()):length()))
Distance3 = round(((entity():pos() - P[3,entity]:pos()):length()))
Distance4 = round(((entity():pos() - P[4,entity]:pos()):length()))
Distance5 = round(((entity():pos() - P[5,entity]:pos()):length()))
Distance6 = round(((entity():pos() - P[6,entity]:pos()):length()))
Distance7 = round(((entity():pos() - P[7,entity]:pos()):length()))
Distance8 = round(((entity():pos() - P[8,entity]:pos()):length()))
Distance9 = round(((entity():pos() - P[9,entity]:pos()):length()))
Distance10 = round(((entity():pos() - P[10,entity]:pos()):length()))
 
Door = 0
if(Distance1<D&P[1,entity]:isAlive()){Door = 1
}elseif(Distance2<D&P[2,entity]:isAlive()){Door = 1
}elseif(Distance3<D&P[3,entity]:isAlive()){Door = 1
}elseif(Distance4<D&P[4,entity]:isAlive()){Door = 1
}elseif(Distance5<D&P[5,entity]:isAlive()){Door = 1
}elseif(Distance6<D&P[6,entity]:isAlive()){Door = 1
}elseif(Distance7<D&P[7,entity]:isAlive()){Door = 1
}elseif(Distance8<D&P[8,entity]:isAlive()){Door = 1
}elseif(Distance9<D&P[9,entity]:isAlive()){Door = 1
}elseif(Distance10<D&P[10,entity]:isAlive()){Door = 1
}
