@name Wire Chat
@inputs Link1:string Link2:string Link3:string 
@outputs Chattxt:string Talk Radio
@outputs StampThen StampNow Stamp
@persist Radio Chatx:string Chaty:string Chatz:string 
@persist Chat1:string Chat2:string Chat3:string Self 
@persist Stamp StampNow StampThen StampThen2 StampThen3
@trigger none
Time=100
interval(Time)
Chat = entity():owner():lastSaid()
K=curtime()-entity():owner():lastSaidWhen()<(Time*1)/1000
Break="#"
S=": "
Name=entity():owner():name()
Brk="`"

if(Chat:find("!radio on")){Radio=1 if(K){print("Radio Enabled")}}
if(Chat:find("!radio off")){Radio=0 if(K){print("Radio Disabled")}}
if(Radio){
    gSetGroup("WireChat")
    gShare(1)
    Chatx=Chat1
    Chaty=Chat2
    Chatz=Chat3
    Chat1=gGetStr("Chat1")
    Chat2=gGetStr("Chat2")
    Chat3=gGetStr("Chat3")
    if(Chat1!=Chatx){Talk=1}else{Talk=0}
#    if(!Self){
#        Units=gGetNum("Self") Self=Units+1 gSetNum("Self",Self)}
    
    
}else{
Chatx=Chat1
Chaty=Chat2
Chatz=Chat3
Chat1=Link1
Chat2=Link2
Chat3=Link3
if(Chatx!=Chat1|Chaty!=Chat2|Chatz!=Chat3){Talk=1}else{Talk=0}
#if(Self){Units=gGetNum("Self") Self=Units-1 gSetNum("Self",Self)
#Self=0}
gShare(0)}

    Chata=Chat1:explode(Brk)
    Chat1=Chata:string(2)
    StampThen=Chata:string(1):toNumber()
    
    Chatb=Chat2:explode(Brk)
    Chat2=Chatb:string(2)
    StampThen2=Chatb:string(1):toNumber()
    
    Chatc=Chat3:explode(Brk)
    Chat3=Chatc:string(2)
    StampThen3=Chatc:string(1):toNumber()
    
    
    StampNow=curtime()
    Stamp=StampNow-StampThen
    Stamp2=StampNow-StampThen2
    Stamp3=StampNow-StampThen3
Chat0=Chat:explode(Break)
Chat01=Chat0:string(2)
Delay=Time*2
if(Talk){
    if(Stamp<Delay){print(Chat1)}
    if(Stamp2<Delay){print(Chat2)}
    if(Stamp3<Delay){print(Chat3)}
Talk=0
}

if(Chat01!=""&K){Chattxt=StampNow+Brk+Name+S+Chat01
if (Radio){gSetStr("Chat",Chattxt)}
}elseif(Stamp>Time*15){Chattxt=""}
if (Radio){gSetStr("Chat",Chattxt)}


