|
bluedragon Novice
Joined: 01 Jul 2003 Posts: 30 Location: USA
|
Posted: Sun Oct 05, 2003 7:01 am
#if statement going off when it shouldn't |
i have this trigger that is set to automatically concoct potions of the given spell when people say "potion <spell>" or any given variants of that - but it goes off when people say something like "not anymore" or anything that starts with "not".. here's the trigger..
pattern: (%w) says, '(%w) *'$
value:
#if (%2 = "conc" or %2 = "conco" or %2 = "concoct" or %2 = "potion" or %2 = "pot") {
#var concocting_bool 1
#var concocting_for %1
#var concocting %remove( @concocting_for, %line)
#var concocting %remove( %2, @concocting)
#var concocting %remove( " says, ' ", @concocting)
concoct '@concocting
}
i tried using pattern: (%w) says, '(%w) (*)'$
and using %3 as concocting variable, but that didn't work either - but since i found a way around that, that's not the issue now..
here's an example of what happens when it works well:
Alexial says, 'potion shield'
concoct 'shield'
83% [623/973h 1473/1473m 750/750v 297366/27000000g 251569920tl] You have created a potion of shield!
give potion Alexial
83% [623/973h 1397/1473m 750/750v 297366/27000000g 251569920tl] You give A potion of shield to Alexial.
and the trigger not working well:
Alexial says, 'not anymore'
concoct 'anymore'
83% [623/973h 1397/1473m 750/750v 297366/27000000g 251569920tl] Cast what?!?
i've tried using #if (%2 = "potion") { or #if (%2 = "conc") { .. and it still won't work
is this an actual bug, or is there some sort of feature i havn't read about somewhere? |
|
|
|
Davos Adept
Joined: 30 Jan 2003 Posts: 228 Location: USA
|
Posted: Sun Oct 05, 2003 7:12 am |
You could try for your IF statement,
Code: |
#VAR conclist conc|conco|concoct|potion|pot
#IF (%ismember(%2,@conclist)) {
#var concocting_bool 1
#var concocting_for %1
#var concocting %remove( @concocting_for, %line)
#var concocting %remove( %2, @concocting)
#var concocting %remove( " says, ' ", @concocting)
concoct '@concocting
} |
|
|
|
|
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Sun Oct 05, 2003 7:27 am |
This may not be what you are looking for, but this is what I came up with.
#TRIGGER {(%w) says, '(%w) (*)'$} {#if (%2 =~ "conc" OR "potion") {#VAR concocting %3;#if (%ismember (%3, @concoclist)) {concoct '@concocting}}}
@concoclist being a stringlist of every concoction you have. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Oct 05, 2003 3:45 pm |
It's not a bug. NOT is a boolean value. NOT = is an operator (the opposite of =). When used alone (with nothing on the left side) it's evaluated as 0.
When someone says "not anymore", you're conditional phrase becomes (with grouping shown):
((not =) ("conc" or (not =)) ("conco" or (not =)) ("concoct" or (not =)) ("potion" or (not =)) "pot")
And this evaluates to 0 1 1 1 1 pot which zMUD accepts as true.
Your problem is simply a failure to define %2 as a string.
("%2" = "conc" or "%2" = "conco" or "%2" = "concoct" or "%2" = "potion" or "%2" = "pot")
I'd probably use something shorter though:
((%pos( %2, concoct) = 1) OR (%pos( %2, potion) = 1)} |
|
|
|
bluedragon Novice
Joined: 01 Jul 2003 Posts: 30 Location: USA
|
Posted: Sun Oct 05, 2003 7:28 pm |
thank you for the responses, i figured the problem came into play with strings.. the first option with using a varlist works for me.. and as i said, for some reason %3 didn't end up working for me - however i'm not worried about it since it all works now
|
|
|
|
Starwaster Newbie
Joined: 05 Sep 2003 Posts: 4
|
Posted: Mon Oct 06, 2003 5:15 pm |
quote: Originally posted by LightBulb
It's not a bug. NOT is a boolean value. NOT = is an operator (the opposite of =). When used alone (with nothing on the left side) it's evaluated as 0.
You don't consider Zmud looking for boolean operators in received text to be a bug?
Not only is that a bug, it could also be a potential security issue.[:0] |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Oct 06, 2003 7:16 pm |
No, I don't consider it to be a bug, but you obviously do. You should submit a bug report.
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon Oct 06, 2003 10:44 pm |
This isn't a bug for the simple reason that %2 should be enclosed in double quotes in the script in question. In nearly every case failure to properly use punctuation such as "", (), and {} is the cause of such script malfunctions. So there is no way anyone can consider user error to be a bug.
|
|
|
|
Backu Novice
Joined: 24 Feb 2003 Posts: 36 Location: USA
|
Posted: Mon Oct 06, 2003 11:31 pm |
erm... why are you using a trig like that? Why not just (%w) says, '{"conc"|"potion"} (%w)'?
|
|
|
|
|
|