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
three_sixteen
Newbie


Joined: 12 Aug 2004
Posts: 2

PostPosted: Thu Aug 12, 2004 2:53 am   

Character replacement in strings.
 
Hey

So.. I don't know a whole lot about zMud scripting, just basic aliases and triggers and whatnot. I want to replace characters in a string so that when I say 'Hello' it says, 'Herro' or when it sees AK it replaces them with a Y.

say Hello. -> you say, 'Herro.'
say Break. -> you say, 'Bray.'

could I get some help? heh
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Thu Aug 12, 2004 3:27 am   your kidding rught
 
hmmm either youe jokeing, or can did not read any of the posts. some one asked the same question not long ago.... check out the post on Wed Aug 11, 2004 11:42 pm.
_________________
<Clever text here>
Reply with quote
three_sixteen
Newbie


Joined: 12 Aug 2004
Posts: 2

PostPosted: Thu Aug 12, 2004 3:34 am   
 
Thats almost helpful, thanks.
Reply with quote
zwimmey
Newbie


Joined: 12 Aug 2004
Posts: 7

PostPosted: Thu Aug 12, 2004 4:55 am   
 
From looking at the scattered contents of these forums, I was able to locate:
#AL lisp {%replace( "%-1", s, ss)}

...which supposedly replaces s with ss. My experience with zmud coding is somewhat rusty,
but I tried:

#alias lisp {{%replace( "%-1", l, r)}{%replace("%-1", L, R)}{%replace("%-1", ak, y)}{%replace("%-1", Ak, Y)}}

...to replace l's with r's, L's with R's, ak's with y's and Ak's with Y's. Output resulted in:

{herro}{hello}{hello}{hello}

...which is somewhat successful, but disheartening. I know I've mangled the parsing horrifically, so if someone
could tell me where I went wrong?

And no, I'm not 'jokeing'.
Reply with quote
SCORNME
Novice


Joined: 25 Jul 2004
Posts: 48
Location: aka Falan

PostPosted: Thu Aug 12, 2004 6:19 am   
 
Lightbulb answered that question in the same post you quoted:
http://www.emobius.com/phpbb/viewtopic.php?t=16114&highlight=lisp
Here's a quote of his parsing for multiple %replace:

Quote:
#AL lisp {%replace( %replace( "%-1", s, ss), S, Ss)}


Following his example, I got:

#alias lisp {%replace( %replace( %replace( %replace("%-1", Ak, ak, L, l), Y, y, R, r)}

...but I can't test it now. Hope it works.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Aug 13, 2004 4:47 pm   
 
Quote:

...if someone could tell me where I went wrong?

You did separate replaces. You should have nested them since you only want the message sent once.
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
zwimmey
Newbie


Joined: 12 Aug 2004
Posts: 7

PostPosted: Sun Aug 15, 2004 4:07 am   
 
#alias lisp {%replace( %replace( %replace( %replace("%-1", Ak, ak, L, l), Y, y, R, r)} apparently generated no output. Sorry, SCORNME.
Reply with quote
SCORNME
Novice


Joined: 25 Jul 2004
Posts: 48
Location: aka Falan

PostPosted: Sun Aug 15, 2004 10:00 am   
 
Looks like I forgot a couple things. How about this?

#alias lisp {%replace( %replace( %replace( %replace("%-1", Ak, ak, L, l), Y, y, R, r)))}
Reply with quote
zwimmey
Newbie


Joined: 12 Aug 2004
Posts: 7

PostPosted: Mon Aug 16, 2004 1:30 am   
 
Still no output, scorn...but I recently redownloaded zmud and figured out something similar that does work.

Step 1: Type
#alias lisp %replace( %replace( %replace( %replace( %replace( "%-1", l, r), L, R), ak, y), Ak, Y), AK, Y)
Step 2: Open Aliases Window
Step 3: insert the word 'say ' (without the 's, with the space) before the first instance of %replace in the value box, resulting in 'say lisp %replace( %replace( %replace( %replace( %replace( "%-1", l, r), L, R), ak, y), Ak, Y), AK, Y)'

Output:

lisp break BREAK breAk ak AK Ak HELLO hello L l = You say 'brey BREY breY y Y Y HERRO herro R r'

I'm sure there's a way to do this with one step, but that's the only way I was able to get it to work, thus its absence from the completed scripts page.


Last edited by zwimmey on Mon Aug 16, 2004 1:46 am; edited 2 times in total
Reply with quote
zwimmey
Newbie


Joined: 12 Aug 2004
Posts: 7

PostPosted: Mon Aug 16, 2004 1:33 am   
 
Question 2:

Is there some sort of symbol that I can susbstitute for a space in the values box? It seems to automatically compact the code, so, for example, if I want " of " to convert automatically to " o' ", it will ignore the specified spaces and replace all instances of the letters "of" inside words (i.e., often= o'ten; blorofsnat=bloro'snat). Likewise, replacing letters at the start of a sentence (i.e., h to ') will ignore my attempts to specify the necessity of a space before said letter, and proceed to replace all instances of that letter wherever they appear in a sentence.
Reply with quote
SCORNME
Novice


Joined: 25 Jul 2004
Posts: 48
Location: aka Falan

PostPosted: Mon Aug 16, 2004 5:23 am   
 
Well, I suppose it didn't work because we didn't include your MUD's command to say.

#AL lisp {SAY %replace( %replace( %replace( %replace( "%-1", Ak, ak, L, l), Y, y, R, r)))}


Edited: removed extra %replace and ().


Last edited by SCORNME on Mon Aug 16, 2004 5:33 am; edited 2 times in total
Reply with quote
zwimmey
Newbie


Joined: 12 Aug 2004
Posts: 7

PostPosted: Mon Aug 16, 2004 5:29 am   
 
null

will try above


Last edited by zwimmey on Mon Aug 16, 2004 6:07 am; edited 3 times in total
Reply with quote
SCORNME
Novice


Joined: 25 Jul 2004
Posts: 48
Location: aka Falan

PostPosted: Mon Aug 16, 2004 5:42 am   
 
Sorry, zwimmey. I was editing my previous entry while you were replying! I had copied your #AL which has 5 instances of %replace, but mine only has 4 strings. If my edited post doesn't work, then I'm at my wit's end until I can get to my home comp.
Reply with quote
zwimmey
Newbie


Joined: 12 Aug 2004
Posts: 7

PostPosted: Mon Aug 16, 2004 6:06 am   
 
results pending
Reply with quote
SCORNME
Novice


Joined: 25 Jul 2004
Posts: 48
Location: aka Falan

PostPosted: Mon Aug 16, 2004 7:04 am   
 
Found this link to a version by Acaila and Lightbulb for replacing words. I suppose it could be modified for your purpose.

#AL lisp {
#VAR Temp "%-1"
#VAR Temp %replace( %replace( %replace( %replace( "%-1", Ak, ak, L, l), Y, y, R, r)))
~say @Temp}
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