|
Leo Newbie
Joined: 10 Nov 2002 Posts: 8 Location: United Kingdom
|
Posted: Mon Dec 09, 2002 9:15 pm
#IF statement |
This is the alias i'm trying to use when I attack.
#alias sj {#if ({@left|@right} = "a broad sword") {sjab @target} {wieldss;sjab @target}}
now it's supposed to do sjab @target if I don't have a broad sword in either hand, and use my equiping alias and then attack otherwise. However, it seems to always be executing the false condition.
I've tried it with left and right = empty. Then left = a broad sword and right = a small wooden shield. Always executes the fase condition. Any ideas?
Leo |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Dec 09, 2002 9:28 pm |
#alias sj {#if (({@left} = "a broad sword") OR ({@right} = "a broad sword")) {sjab @target} {wieldss;sjab @target}}
LightBulb
Senior Member |
|
|
|
Leo Newbie
Joined: 10 Nov 2002 Posts: 8 Location: United Kingdom
|
Posted: Tue Dec 10, 2002 9:58 am |
still having problems, looking at the condition values it seems to refuse to match up even when I know that the value of left or right is 'a broad sword'.
#if (({@left} = "a broad sword") OR ({@right} = "a broad sword")) {sjab @target} {wieldss;sjab @target}
Is for some reason always false, whereas removing the "" leads to an exression which is always true.
I'm thinking it might be my capturing of what's in either hand. This is done with these triggers.
#trigger {You start to wield (*) in your left hand.} {#var left %1}
#trigger {You start to wield (*) in your right hand.} {#var right %1}
Which work on the follow line from the MUD
You start to wield a broad sword in your left hand.
Hope that makes sense.
Leo |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Tue Dec 10, 2002 12:44 pm |
Yes, you are right, the problem is when you capture the text. Since the * in the triggers match more than one word, when %1 gets replaced in the commands of the trigger, it ends up looking something like this:
#VAR left a broad sword
which, according to the syntax of the #VAR command, tells zMUD to create a variable names "left", with a value of "a", defulat value of "broad" and in the "sword" class. To prevent this, you need to use the command like this:
#VAR left "%1"
Kjata |
|
|
|
Leo Newbie
Joined: 10 Nov 2002 Posts: 8 Location: United Kingdom
|
Posted: Tue Dec 10, 2002 5:26 pm |
Ah thanks, that's got the capturing working right. Still can't quite get the red part to be true though.
Leo |
|
|
|
Leo Newbie
Joined: 10 Nov 2002 Posts: 8 Location: United Kingdom
|
Posted: Tue Dec 10, 2002 5:36 pm |
Woohoo! Got it to work with a slight modification. Instead of trying to match a string I just created a boolean variable that is true when wielding a sword and false otherwise.
That works perfectly, so thanks for all the help.
Leo |
|
|
|
|
|