|
three_sixteen Newbie
Joined: 12 Aug 2004 Posts: 2
|
Posted: 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 |
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: 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> |
|
|
|
three_sixteen Newbie
Joined: 12 Aug 2004 Posts: 2
|
Posted: Thu Aug 12, 2004 3:34 am |
Thats almost helpful, thanks.
|
|
|
|
zwimmey Newbie
Joined: 12 Aug 2004 Posts: 7
|
Posted: 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'. |
|
|
|
SCORNME Novice
Joined: 25 Jul 2004 Posts: 48 Location: aka Falan
|
Posted: 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. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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. |
|
|
|
zwimmey Newbie
Joined: 12 Aug 2004 Posts: 7
|
Posted: 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.
|
|
|
|
SCORNME Novice
Joined: 25 Jul 2004 Posts: 48 Location: aka Falan
|
Posted: 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)))} |
|
|
|
zwimmey Newbie
Joined: 12 Aug 2004 Posts: 7
|
Posted: 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 |
|
|
|
zwimmey Newbie
Joined: 12 Aug 2004 Posts: 7
|
Posted: 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. |
|
|
|
SCORNME Novice
Joined: 25 Jul 2004 Posts: 48 Location: aka Falan
|
Posted: 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 |
|
|
|
zwimmey Newbie
Joined: 12 Aug 2004 Posts: 7
|
Posted: 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 |
|
|
|
SCORNME Novice
Joined: 25 Jul 2004 Posts: 48 Location: aka Falan
|
Posted: 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.
|
|
|
|
zwimmey Newbie
Joined: 12 Aug 2004 Posts: 7
|
Posted: Mon Aug 16, 2004 6:06 am |
results pending
|
|
|
|
SCORNME Novice
Joined: 25 Jul 2004 Posts: 48 Location: aka Falan
|
Posted: 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} |
|
|
|
|
|
|
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
|
|