@name E2 Language Convertor
@outputs Targ:entity Translate Convert Z Max SayIt Reset
@persist [Said Original]:array Say:string
@trigger all
runOnChat(1)
runOnTick(1)

if(first()){
I=0  
Z = 1  
}

O = owner()
Said = O:lastSaid():explode("")
Said2 = O:lastSaid():explode(" ")

if(chatClk(O)){
if(Said2[1,string] == "!set"){
hideChat(1)  

if(findPlayerByName(Said2[2,string]):isPlayer()){
Targ = findPlayerByName(Said2[2,string])
print("Target is now : " + Targ:name())
setName("E2 Language Convertor ["+owner():name()+"]["+Targ:name()+"]")
}

}else{
if(SayIt == 0 & Said[1,string] == "."){
hideChat(1)
Convert = 1
Max = O:lastSaid():length()
}
}    
}


if(chatClk(Targ)){

if(Said[1,string] == "$"){
Translate = 1
Max = Targ:lastSaid():length()
}
    
}

if(Convert == 1){
    
for(Z2 = 0 ,Max){  
Original[Z2,string] = Said[Z2,string]:lower()
}    
 
if(Z2 >= Max){
Convert = 2
print("Converting..")
Say = ""    
}
   
}

if(Convert == 2){
    
for(P=0,Original:count()){    

if(Original[P,string] == "a"){
Say = Say + "i"    
}

if(Original[P,string] == "b"){
Say = Say + "u"    
}

if(Original[P,string] == "c"){
Say = Say + "j"    
}

if(Original[P,string] == "d"){
Say = Say + "z"   
}
  
if(Original[P,string] == "e"){
Say = Say + "q"    
}

if(Original[P,string] == "f"){
Say = Say + "o"    
}

if(Original[P,string] == "g"){
Say = Say + "w"    
}

if(Original[P,string] == "h"){
Say = Say + "x"    
}
 
if(Original[P,string] == "i"){
Say = Say + "k"    
}

if(Original[P,string] == "j"){
Say = Say + "n"    
}

if(Original[P,string] == "k"){
Say = Say + "e"    
}

if(Original[P,string] == "l"){
Say = Say + "d"    
}

if(Original[P,string] == "m"){
Say = Say + "b"    
}

if(Original[P,string] == "n"){
Say = Say + "v"    
}

if(Original[P,string] == "o"){
Say = Say + "l"    
}

if(Original[P,string] == "p"){
Say = Say + "y"    
}

if(Original[P,string] == "q"){
Say = Say + "h"    
}

if(Original[P,string] == "r"){
Say = Say + "c"    
}

if(Original[P,string] == "s"){
Say = Say + "g"    
}

if(Original[P,string] == "t"){
Say = Say + "a"    
}

if(Original[P,string] == "u"){
Say = Say + "t"    
}

if(Original[P,string] == "v"){
Say = Say + "r"    
}

if(Original[P,string] == "w"){
Say = Say + "s"    
}

if(Original[P,string] == "x"){
Say = Say + "p"    
}

if(Original[P,string] == "y"){
Say = Say + "m"    
}

if(Original[P,string] == "z"){
Say = Say + "f"    
}

if(Original[P,string] == " "){
Say = Say + " "    
}

}

if(P >= Original:count()){
SayIt = 1
print("Converted")
hint(Say,7)
Convert = 0
P =0
}
}



if(Translate == 1){
    
while(Z <= Max){
Z+=1    
Original[Z,string] = Said[Z,string]
}

if(Z >= Max){
Translate =2
print("Copying Done.")
Say = ""
}
    
}

if(Translate == 2){

for(P=0,Original:count()){
    
if(Original[P,string] == "i"){
Say = Say + "a"    
}

if(Original[P,string] == "u"){
Say = Say + "b"    
}

if(Original[P,string] == "j"){
Say = Say + "c"    
}

if(Original[P,string] == "z"){
Say = Say + "d"    
}
  
if(Original[P,string] == "q"){
Say = Say + "e"    
}

if(Original[P,string] == "o"){
Say = Say + "f"    
}

if(Original[P,string] == "w"){
Say = Say + "g"    
}

if(Original[P,string] == "x"){
Say = Say + "h"    
}
 
if(Original[P,string] == "k"){
Say = Say + "i"    
}

if(Original[P,string] == "n"){
Say = Say + "j"    
}

if(Original[P,string] == "e"){
Say = Say + "k"    
}

if(Original[P,string] == "d"){
Say = Say + "l"    
}

if(Original[P,string] == "b"){
Say = Say + "m"    
}

if(Original[P,string] == "v"){
Say = Say + "n"    
}

if(Original[P,string] == "l"){
Say = Say + "o"    
}

if(Original[P,string] == "y"){
Say = Say + "p"    
}

if(Original[P,string] == "h"){
Say = Say + "q"    
}

if(Original[P,string] == "c"){
Say = Say + "r"    
}

if(Original[P,string] == "g"){
Say = Say + "s"    
}

if(Original[P,string] == "a"){
Say = Say + "t"    
}

if(Original[P,string] == "t"){
Say = Say + "u"    
}

if(Original[P,string] == "r"){
Say = Say + "v"    
}

if(Original[P,string] == "s"){
Say = Say + "w"    
}

if(Original[P,string] == "p"){
Say = Say + "x"    
}

if(Original[P,string] == "m"){
Say = Say + "y"    
}

if(Original[P,string] == "f"){
Say = Say + "z"    
}

if(Original[P,string] == " "){
Say = Say + " "    
}
    
}

if(P >= Original:count()){
Translate = 0
Z = 0
print(Targ:name() + ": " + Say)
P = 0
Reset = 1
}

}


if(SayIt){
    
timer("wait",1000)
if(clk("wait")){  
concmd("say " + Say) 
}

timer("wait2",2000)
if(clk("wait2")){
SayIt = 0  
Reset = 1
}
}

if(Reset){
Convert = 0
P =0   
stoptimer("wait")
stoptimer("wait2")
Max = 0
Say =""
Translate = 0
Z = 0
Reset = 0
}

