|
hogarius Adept
Joined: 29 Jan 2003 Posts: 221 Location: islands.genesismuds.org
|
Posted: Sun Dec 03, 2006 2:43 am
[1.18] Problem with %pos() in SWITCH |
Simutronics' Modus Operandi. I am submitting this as a bug report and also posting it in the CMUD forum.
I think the syntax is correct in the following, but it doesn't work. This is part of a GSL-type trigger with the pattern "P" and Case Sensitive, Trigger on Trigger and Trigger on Newline checkboxes marked. @BodyPos is used to display on the status bar whether I am standing, sitting, kneeling or lying down.
Code: |
$PP=%gsl(P);
BodyPos="STANDING ";
#switch
(%pos("H",$PP)>0) {BodyPos="SITTING "};
:
: |
The variable @BodyPos does not get loaded correctly for the status bar, and the contents of @BodyPos end up being sent to the MUD whenever the trigger fires.
I ended up having to assign the value "H" to the variable @HH externally and use the following.
Code: |
$PP=%gsl(P);
BodyPos="STANDING ";
#switch
(%pos(@HH,$PP)>0) {BodyPos="SITTING "};
:
: |
I'm fine with it, now that it works, but shouldn't the first method work also? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Dec 03, 2006 10:31 am |
Firstly, if your #switch has more than one line, you don't need semicolons after each of them. Doing that will force it to be parsed as a new command, which is probably not what you intended. Similarly, since the #switch is on a new line, you don't need a semicolon after BodyPos=.
To test if that fixes it, I had to change the %gsl(P) part to a string of letters, I used HAYBS. The final script was this:
Code: |
$PP=HAYBS
BodyPos="STANDING "
#switch
(%pos("H",$PP)) {BodyPos="SITTING "} |
And it works fine for me.
(You don't need > 0 for the %pos because it will automatically evaluate true if it's a number 1 or more.)
EDIT: See the other thread for some more input on this problem. |
|
|
|
|
|
|
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
|
|