Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Thu Feb 12, 2004 8:41 am   

Script for translating a "code"
 
(using version 6.62, btw)

I'm trying to adapt a scrip that i found on the finished script forum that originally was to convert things to morse code and back to make my own code that i could use. I want to be able to type in something to send to my friend, have the alias encode it, and then have a trigger to decode it on my friend's end, and vice versa.

Here is the code i have atm:

#ALIAS {convert} {
#VAR morse %replace(@morse," ","/ ")
#VAR morse %replace(@morse,a,".- ")
#VAR morse %replace(@morse,b,"-... ")
#VAR morse %replace(@morse,c,"-.-. ")
#VAR morse %replace(@morse,d,"-.. ")
#VAR morse %replace(@morse,e,". ")
#VAR morse %replace(@morse,f,"..-. ")
#VAR morse %replace(@morse,g,"--. ")
#VAR morse %replace(@morse,h,".... ")
#VAR morse %replace(@morse,i,".. ")
#VAR morse %replace(@morse,j,".--- ")
#VAR morse %replace(@morse,k,"-.- ")
#VAR morse %replace(@morse,l,".-.. ")
#VAR morse %replace(@morse,m,"-- ")
#VAR morse %replace(@morse,n,"-. ")
#VAR morse %replace(@morse,o,"--- ")
#VAR morse %replace(@morse,p,".--. ")
#VAR morse %replace(@morse,q,"--.- ")
#VAR morse %replace(@morse,r,".-. ")
#VAR morse %replace(@morse,s,"... ")
#VAR morse %replace(@morse,t,"- ")
#VAR morse %replace(@morse,u,"..- ")
#VAR morse %replace(@morse,v,"...- ")
#VAR morse %replace(@morse,w,".-- ")
#VAR morse %replace(@morse,x,"-..- ")
#VAR morse %replace(@morse,y,"-.-- ")
#VAR morse %replace(@morse,z,"--.. ")
#VAR morse %replace(@morse,A,".- ")
#VAR morse %replace(@morse,B,"-... ")
#VAR morse %replace(@morse,C,"-.-. ")
#VAR morse %replace(@morse,D,"-.. ")
#VAR morse %replace(@morse,E,". ")
#VAR morse %replace(@morse,F,"..-. ")
#VAR morse %replace(@morse,G,"--. ")
#VAR morse %replace(@morse,H,".... ")
#VAR morse %replace(@morse,I,".. ")
#VAR morse %replace(@morse,J,".--- ")
#VAR morse %replace(@morse,K,"-.- ")
#VAR morse %replace(@morse,L,".-.. ")
#VAR morse %replace(@morse,M,"-- ")
#VAR morse %replace(@morse,N,"-. ")
#VAR morse %replace(@morse,O,"--- ")
#VAR morse %replace(@morse,P,".--. ")
#VAR morse %replace(@morse,Q,"--.- ")
#VAR morse %replace(@morse,R,".-. ")
#VAR morse %replace(@morse,S,"... ")
#VAR morse %replace(@morse,T,"- ")
#VAR morse %replace(@morse,U,"..- ")
#VAR morse %replace(@morse,V,"...- ")
#VAR morse %replace(@morse,W,".-- ")
#VAR morse %replace(@morse,X,"-..- ")
#VAR morse %replace(@morse,Y,"-.-- ")
#VAR morse %replace(@morse,Z,"--.. ")
}
#ALIAS {revert} {
#VAR morse %replace(@morse,"-... ",b)
#VAR morse %replace(@morse,"-.-. ",c)
#VAR morse %replace(@morse,"..-. ",f)
#VAR morse %replace(@morse,".... ",h)
#VAR morse %replace(@morse,".--- ",j)
#VAR morse %replace(@morse,".-.. ",l)
#VAR morse %replace(@morse,".--. ",p)
#VAR morse %replace(@morse,"--.- ",q)
#VAR morse %replace(@morse,"...- ",v)
#VAR morse %replace(@morse,"-..- ",x)
#VAR morse %replace(@morse,"-.-- ",y)
#VAR morse %replace(@morse,"--.. ",z)
#VAR morse %replace(@morse,"-.. ",d)
#VAR morse %replace(@morse,"--. ",g)
#VAR morse %replace(@morse,"-.- ",k)
#VAR morse %replace(@morse,"--- ",o)
#VAR morse %replace(@morse,".-. ",r)
#VAR morse %replace(@morse,"... ",s)
#VAR morse %replace(@morse,"..- ",u)
#VAR morse %replace(@morse,".-- ",w)
#VAR morse %replace(@morse,".. ",i)
#VAR morse %replace(@morse,"-- ",m)
#VAR morse %replace(@morse,"-. ",n)
#VAR morse %replace(@morse,".- ",a)
#VAR morse %replace(@morse,". ",e)
#VAR morse %replace(@morse,"- ",t)
#VAR morse %replace(@morse,"-...",b)
#VAR morse %replace(@morse,"-.-.",c)
#VAR morse %replace(@morse,"..-.",f)
#VAR morse %replace(@morse,"....",h)
#VAR morse %replace(@morse,".---",j)
#VAR morse %replace(@morse,".-..",l)
#VAR morse %replace(@morse,".--.",p)
#VAR morse %replace(@morse,"--.-",q)
#VAR morse %replace(@morse,"...-",v)
#VAR morse %replace(@morse,"-..-",x)
#VAR morse %replace(@morse,"-.--",y)
#VAR morse %replace(@morse,"--..",z)
#VAR morse %replace(@morse,"-..",d)
#VAR morse %replace(@morse,"--.",g)
#VAR morse %replace(@morse,"-.-",k)
#VAR morse %replace(@morse,"---",o)
#VAR morse %replace(@morse,".-.",r)
#VAR morse %replace(@morse,"...",s)
#VAR morse %replace(@morse,"..-",u)
#VAR morse %replace(@morse,".--",w)
#VAR morse %replace(@morse,"..",i)
#VAR morse %replace(@morse,"--",m)
#VAR morse %replace(@morse,"-.",n)
#VAR morse %replace(@morse,".-",a)
#VAR morse %replace(@morse,".",e)
#VAR morse %replace(@morse,"-",t)
#VAR morse %replace(@morse,"/ "," ")
}
#ONINPUT {tp &{morse}} {convert;tell whoever @morse}
#TRIGGER {Whoever tells you ~'&{morse}~'} {revert;#ECHO whoever tells you ~"@morse"}


This works for the morse code, but my problem is that that code takes up too much room, and is rather easy to break. I wanted to make it so that I could have letters stand for other letters, as in if i type "tp a" it would send "tell whoever b" and then on the other end, it would change "whoever tells you b" to "whoever tells you a". (Hope that makes sense)

My main problem with this is that the way this does it, the replacing is sequential. If i change something to the letter "s" through one of the top %replace things, and one of my lower ones has "s" as the thing it is supposed to replace, i'll end up with it being replaced again. Is there any way to make it so all the replacements happen all at once, or so that each character can only be replaced once per use of that code, or maybe there's some other way around it? I appreciate the help :D.

(Btw, thanks Yvves for the original code. You must have a LOT of time on your hands Wink )
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Thu Feb 12, 2004 3:47 pm   
 
language
http://www.zuggsoft.com/forum/topic.asp?TOPIC_ID=13808

talk backwards
http://www.zuggsoft.com/forum/topic.asp?TOPIC_ID=10875

decoder ring
http://www.zuggsoft.com/forum/topic.asp?TOPIC_ID=10906

These are all scripts I wrote that do just that.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Thu Feb 12, 2004 11:00 pm   
 
You might also want to look at the %subchar function. If I recall correctly it is designed to not make recursive substitutions.
Reply with quote
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Fri Feb 13, 2004 2:17 am   
 
Wow, %subchar is perfect :D Just tried it out, and it seems to ge working.
Reply with quote
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Fri Feb 13, 2004 7:01 am   
 
Ok, one last quick question. This is more streamlining than anything else. With the above, i want it to save to a var when one of the members of the clan i'm in sends me a tell or chats or whatever. I have the members of the clan on the variable @Clan and I can get it to capture what they say pretty easily. Right now what i have is this (revert is my alias for decoding):

#TR {{@Clan} tells you ~'&{code}~'} {revert;#ECHO {@Clan} tells you ~"@code~"}

Unfotunately, what this does is give me my clan list when i get the Echo, instead of the specific person who sent it. I know i can do this using a bunch of different triggers, but that is rather annoying to do and maintain as new members join. Is there any way to get zmud to recognize which person on my clan list sent the message and use that in the #Echo? Thanks for this last bit of help.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Fri Feb 13, 2004 12:28 pm   
 
#TR {({@Clan}) tells you ~'&{code}~'} {revert;#ECHO %1 tells you ~"@code~"}
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Fri Feb 13, 2004 1:12 pm   
 
%subchar
I really need to look thought those help files more often, I have been Reading those files and making scripts for so long and I have never seen subchar. Makes me wonder what else I am missing.

Do you think this was an upgrade and not in the lower versions?
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net