About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
bluedragon
Novice


Joined: 01 Jul 2003
Posts: 30
Location: USA

PostPosted: 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?
Reply with quote
Davos
Adept


Joined: 30 Jan 2003
Posts: 228
Location: USA

PostPosted: 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
}
Reply with quote
user0101
Apprentice


Joined: 01 Aug 2003
Posts: 100
Location: USA

PostPosted: 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.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: 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)}
Reply with quote
bluedragon
Novice


Joined: 01 Jul 2003
Posts: 30
Location: USA

PostPosted: 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
Reply with quote
Starwaster
Newbie


Joined: 05 Sep 2003
Posts: 4

PostPosted: 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]
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: 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.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: 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.
Reply with quote
Backu
Novice


Joined: 24 Feb 2003
Posts: 36
Location: USA

PostPosted: Mon Oct 06, 2003 11:31 pm   
 
erm... why are you using a trig like that? Why not just (%w) says, '{"conc"|"potion"} (%w)'?
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