@name Dusty's E2
@inputs EGP:wirelink
@persist Found:array

runOnChat(1)





if(chatClk(owner())){
    CC = owner():lastSaid():explode(" ")
    if(CC:string(1)=="/ref"){
        hideChat(1)
        findByClass(entity():type())
        findExcludeEntity(entity())
        findSortByDistance(entity():pos())
        
        Found = findToArray()
        hint(Found:count()+" found", 4)
        
        }
    }

if(first() | duped()){
    EGP:egpClear()
    EGP:egpText(1, "E2 Finder", vec2(200, 30))
    EGP:egpSize(1, 24)
    
    }
    
    function void drawScreen(S:wirelink, F:array){
        for(I=1, F:count()){
            Temp = F[I, entity]
            Temp:teleport(entity():pos()+vec(randint(100), randint(100) ,randint(100)))
            S:egpText(2+1, Temp:owner():name() + "'s e2          Pos: (" + round(Temp:pos():x())+","+round(Temp:pos():y())+","+round(Temp:pos():z())+")" , vec2(30, 40+30*I))
            }
        
    
    }

if(chatClk(owner())){
    CC = owner():lastSaid():explode(" ")
    if(CC:string(1)=="/ref"){
        drawScreen(EGP, Found)
        }
    }
