|
Belmyrddyn Magician
Joined: 17 Oct 2001 Posts: 371 Location: USA
|
Posted: 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 |
|
|
|
Crymson4 Novice
Joined: 20 Nov 2001 Posts: 35 Location: USA
|
Posted: 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 |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Dec 21, 2001 5:05 pm |
You might try
#VAR RHand {%replace(%1,%s," ")}
LightBulb |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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 |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: 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. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: 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 |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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 |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: 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.
|
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: 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 |
|
|
|
|
|