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
Belmyrddyn
Magician


Joined: 17 Oct 2001
Posts: 371
Location: USA

PostPosted: Fri Dec 21, 2001 3:21 pm   

Bizarre Trigger
 
Okay I need to capture something like this;
GSman ivory-hilted claymore
Obviously this is a bit of an odd thing to capture... The 'GSm' part is always there, and everything after that is what is in my right hand. The problem when I try to reduce all the excess whitespace down to one whitespace, I hit a irritating problem.
#VAR RHand %replace("%1", %s, " ")
I end up with something like RHand = an
It cuts off everything after the first whitespace.

Any ideas?


Belmyrddyn
Reply with quote
Crymson4
Novice


Joined: 20 Nov 2001
Posts: 35
Location: USA

PostPosted: Fri Dec 21, 2001 4:42 pm   
 
I believe in one of the earlier posts something similar was addressed. Try putting the text you want to capture in parthesis () That might solve your problem.

-=Crymson

Reality is the effect of alcohol deficiency
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Dec 21, 2001 5:05 pm   
 
You might try

#VAR RHand {%replace(%1,%s," ")}

LightBulb
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Dec 23, 2001 1:38 am   
 
In case you haven't caught it, here's what's happening with the original script (although my trigger might not be identical)

#TR {GSm(%*)$ {#VAR RHand %replace("%1",%s," "}
issues the command (for GSman ivory-hilted claymore)
#VAR RHand an ivory-hilted claymore
which creates/updates the variable RHand with value "an" and default value "ivory-hilted" in the class "claymore".


LightBulb
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Dec 23, 2001 7:05 am   
 
#TR {GSm(%*)$} {#VAR RHand %trim("%1");#WHILE (%pos(" ",@RHand) {#VAR RHand %replace(@RHand," "," ")}}

I Don't think %s works inside replace. Also the trigger you gave us really wasn't displaying any whitespace so I think everyone was a little confused.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Dec 23, 2001 1:38 pm   
 
Replacing a space with a space won't do it. Plus, the script will also go into an infinite loop because the string will always have a whitespace.

The following should do what you want:
#TRIGGER {GSm(%*)$} {#VAR char "";#VAR RHand %trim("%1");#LOOP 1,%len(@RHand) {#IF ((%copy(@RHand, %i, 1) = " ") & (@char <> " ")) {#VAR char %copy(@RHand, %i, 1);#VAR RHand %concat(@RHand, @char)}}}


Kjata
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Dec 23, 2001 8:55 pm   
 
Since Belmyrddyn never gave us a trigger I made one up. You're right that there doesn't appear to actually be any extra white space to be eliminated which means the replace routine can be completely eliminated. All that's needed is to modify the #VAR statement to include an extra set of braces as I suggested earlier...

#TR {GSm(%*)$ {#VAR RHand {%1}}
which produces the #VAR statement:

#VAR RHand {an ivory-hilted claymore}
which produces the variable @RHand with value "an ivory-hilted claymore" as desired.

My second post was not a suggested fix but an explanation of the problem to show why the fix I suggested was needed.


LightBulb
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Dec 23, 2001 9:00 pm   
 
Hrm, the forum has some code in it to reduce whitespace. I typed 2 spaces in there and it made it 1.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Mon Dec 24, 2001 12:36 pm   
 
There are extra spaces in the line, it is just that the forum eats up extra spaces (it is HTML after all). If you click on the little icon to reply directly to Belmyrddyn's post instead of the Reply to Topic link at the bottom, you will see the original message without being formatted by the forum. The line actually looks like this:
GSman         ivory-hilted   claymore

Kjata
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