@name Alphabet Converter
@outputs [List List2]:table Converted:array Target:entity
@persist [Alphabet Orginal LastSay TargetSay]:array
@persist [Say SayC]:string
@persist Letter2 Done Generated I Count Random
@persist GTable:gtable
runOnTick(1)
runOnChat(1)

if(first()|dupefinished()) {
    GTable = gTable("FailCookies",1)
    I = 1
    SayC = ""
    Letter2 = 1
    Letters = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,1,2,3,4,5,6,7,8,9,0"
    Alphabet = Letters:lower():explode(",")
    Orginal = Alphabet:clone()
    Count = Alphabet:count()
}
LastSay = owner():lastSaid():explode(" ")
if(LastSay[1,string]=="/t") {
    hideChat(1)
    if(findPlayerByName(LastSay[2,string])) {
        if(chatClk(owner())) {
            Target = findPlayerByName(LastSay[2,string])
            Generated = 0
        }

            if(I<=Count&!Generated) {
                Random = randint(1,Alphabet:count())
                Converted[I,string] = Alphabet[Random,string]
                List[Orginal[I,string],number] = I
                List2[Converted[I,string],number] = I
                #print(Orginal[I,string]+" = "+Converted[I,string])
                Alphabet:removeString(Random)
                I++
            } elseif(changed(I>Count)&!Generated) {
                hint("Generation Complete!",7)
                Generated = 1
                GTable[1,array] = Converted:clone()
                GTable[2,table] = List:clone()
                GTable[3,table] = List2:clone()
                timer("delay",600)
                SayC = "$&!GENERATED!&$"
            }
    }
} elseif(owner():lastSaid():sub(0,1)=="!"&Generated) {
    hideChat(1)
    if(chatClk(owner())) {
        Say = owner():lastSaid():sub(2,owner():lastSaid():length())
        Letter2 = 1
        SayC = ""
        Done = 0
    }
        if(Letter2<=Say:length() & !Done) {

            if(List[Say:sub(Letter2,Letter2),number]) {
                SayC = SayC+Say:replace(Orginal[List[Say:sub(Letter2,Letter2),number],string],Converted[List[Say:sub(Letter2,Letter2),number],string]):sub(Letter2,Letter2)
                Letter2++
            } else {
                SayC = SayC+Say:sub(Letter2,Letter2)
                Letter2++
            }
        }
        if(Letter2>Say:length()) {
            Letter2 = 1
            Done = 1
            timer("delay",600)
        }
} else {
    hideChat(0)
}

if(Target:lastSaid():sub(0,1)=="!"&chatClk(Target)&Generated) {
        Say = Target:lastSaid():sub(2,Target:lastSaid():length())
        SayC = Say
        print(SayC)
} elseif(Target:lastSaid():sub(0,15)=="$&!GENERATED!&$") {
    Converted = GTable[1,array]
    List = GTable[2,table]
    List2 = GTable[3,table]

}
if(clk("delay")) {
    concmd("say #"+SayC)
}
if(Target) {
    TargetSay = Target:lastSaid():explode(" ")
}
