@name E2_finder
@inputs S:wirelink
@outputs X Y Up Line Tar:entity Dir:vector
@persist E2:entity Array:array Box:vector Corn1:vector Corn2:vector Corn3:vector Dist1 Mne:string Dist2 Screen:entity We:vector As We2:vector As2 Df Length Space:string Down Name:string Dr Dr2 ExLin Mrk
if(first()|dupefinished()){holoCreate(1)
runOnTick(1)
holoModel(1,"hqsphere2")
holoColor(1,vec(255,0,0))
holoAlpha(1,0)
Tar=noentity()
Screen=entity():isWeldedTo()
S[2041]=1
S[2041]=0
Row=1
Dist1=0
As=0
X=0
Y=0}
if((->S&!Box)|dupefinished()){Box=Screen:boxSize()
Corn1=Screen:pos()-Screen:forward()*(Box:y()/2)+Screen:right()*(Box:x()/2)
Corn1=Corn1+(Screen:forward()*3.2)
Corn2=Screen:pos()-Screen:forward()*(Box:y()/2)-Screen:right()*(Box:x()/2)
Corn2=Corn2+(Screen:forward()*3.2)
Corn3=Screen:pos()+Screen:forward()*(Box:y()/2)+Screen:right()*(Box:x()/2)
Corn3=Corn3-(Screen:forward()*3.2)
Dist1=Corn2:distance(Corn1)
Dist2=Corn3:distance(Corn1)}
Mne="Haba"
if(owner():aimEntity()==Screen&owner():keyUse()){
We=(owner():aimPos()-Corn1)*Screen:right()
As=abs(We:x()+We:y()+We:z())
X=floor((As/Dist1)*29)
We2=(owner():aimPos()-Corn1)*Screen:forward()
As2=abs(We2:x()+We2:y()+We2:z())
Y=floor((As2/Dist2)*18)}
if(Tar){Df=1}else{Df=0}      
findByClass(entity():type())
Array = findToArray()
Mne=Mne+"fflof"
ExLin=Array:count()-14
S:writeString("Who's E2:  ",0,0,111,999)
S:writeString("Pos:"+" ":repeat(15),11,0,111,999)
S:writeString(" ":repeat(29),0,1,111,999)
S:writeString(" ":repeat(29),0,16,111,999)
S:writeString("Made ",0,17,111,999)
if((X==27|X==28)&Y==1&owner():keyUse()){S:writeString("^",29,1,999,119)
Up=1}else{S:writeString("^",29,1,999,159)
Up=0}
if((X==27|X==28)&Y==16&owner():keyUse()){S:writeString("v",29,16,999,119)
Down=1}else{S:writeString("v",29,16,999,159)
Down=0}
if($Up&Up){if(!Line)
{Screen:soundPlay(1,soundDuration("buttons/button10.wav"),"buttons/button10.wav")}   
if(Line>0){Line--
Screen:soundPlay(1,soundDuration("buttons/button14.wav"),"buttons/button14.wav")
}
}
S:writeString("by ",5,17,111,999)
if($Down&Down){if((Line==ExLin)|ExLin<0)
{Screen:soundPlay(1,soundDuration("buttons/button10.wav"),"buttons/button10.wav")}
if(ExLin>0&Line!=ExLin){Line++
Screen:soundPlay(1,soundDuration("buttons/button14.wav"),"buttons/button14.wav")}
}
S:writeString(Mne+" ":repeat(13),8,17,111,999)
if(X!=27&X!=28){if(Array[Y-1+Line,entity])
{Tar=Array[Y-1+Line,entity]}else{Tar=noentity()}
}
if(ExLin>0){Mrk=floor((Line/ExLin)*13)}
if(Tar){Dir=(Tar:pos()-(owner():pos()+vec(0,0,64))):normalized()
holoAlpha(1,150)
holoPos(1,(owner():pos()+vec(0,0,64))+(Dir*100))}else{holoAlpha(1,0)}
if($Df&!Tar){Screen:soundPlay(3,soundDuration("buttons/blip1.wav"),"buttons/blip1.wav")}
for(I=1,Array:count()){if(I>14){break}
E2=Array[I+Line,entity]
Length=((round(E2:pos())):toString()):length()
if(I==Mrk+1){S:writeString(" ",29,I+1,999,229)}else{S:writeString(" ",29,I+1,999,559)}
Space=" ":repeat(19-Length)
if(Tar==E2){if($Y){Dr=0}
if(Dr>50&Dr<110){Dr=Dr+0.8}
else{Dr=Dr+0.2}
if(Dr==183){Dr=1}
Dr2=round(sin(Dr)*(E2:owner():name():length()-8))
Name=E2:owner():name():left(8+Dr2)
S:writeString(Name:right(8)+"  ",0,I+1,999,119)
S:writeString(round(E2:pos())+Space,10,I+1,999,119)
if($Y&X!=27&X!=28){Screen:soundPlay(2,soundDuration("buttons/button3.wav"),"buttons/button3.wav")}
}else{S:writeString(E2:owner():name():left(8)+"  ",0,I+1,696,333)
S:writeString(round(E2:pos())+Space,10,I+1,349,333)}
}
for(I=1,14-Array:count()){S:writeString(" ":repeat(30),0,Array:count()+1+I,111,333)}
if(Line>0&Array:count()<15){Line=0}
