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
Lench
Beginner


Joined: 26 Jan 2004
Posts: 21
Location: Norway

PostPosted: Sun Feb 06, 2005 12:10 pm   

Trigger with variables.
 
i made a trigger like this

#trigger %1's wounds start to bleed.
#if (%1=@variable1) {dothis}
#if (%1=@variable2) {dothat}
#if (%1=@variable3) {dothis instead}

what happened was that regardless of wether %1 matched a variable, all if tests reported TRUE and ran their dothis dothat and dothis instead.

Wich wasnt exactly what i planned....

Ideas?
_________________
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Sun Feb 06, 2005 4:57 pm   
 
You should be using %w rather than %1 to match a name.

Try the following
#trigger {(%w)'s wounds start to bleed.} {#if (%1=@variable1) {dothis};#if (%1=@variable2) {dothat};#if (%1=@variable3) {dothis instead}}
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Feb 06, 2005 8:05 pm   
 
What did it match on? ZMud generally doesn't verify the variable contents before doing the evaluation, so without quotes it will only use the 1-word value adjacent to the comparison sign (in this case, =):

Ted Kennedy = @President evalatuates to either Ted 0 (the word Kennedy is not contained in @President) or Ted 1 (the word Kennedy is contained in @President). Since "Ted 0" nor "Ted 1" = 0, the whole thing always evaluates to True.
_________________
EDIT: I didn't like my old signature
Reply with quote
a5hi5m
Beginner


Joined: 04 Mar 2004
Posts: 24
Location: Australia

PostPosted: Sun Feb 06, 2005 9:58 pm   
 
If only 1 of the if statements should come true, you could nest them in some sort of order, such as ..

#trigger {(%w)'s wounds start to bleed. } {#if (%1=@variable1) {dothis} {#if (%1=@variable2) {dothat} {#if (%1=@variable3) {dothis instead} {#noop} }}}
_________________
Smoking@BatMUD
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Feb 07, 2005 12:56 am   
 
What Matt is saying is that you need to put some kind of delimiter, such as double-quotes, around %1 in the #IF conditions. Otherwise, if %1 is longer than one word (contains spaces) then your #IF conditions will always evaluate to true and all the commands will be done. Since you used %1 in the pattern, which is the equivalent of *, your pattern can and will match any number of words.
Code:
#trigger {(*)'s wounds start to bleed.} {
#if ("%1"=@variable1) {dothis}
#if ("%1"=@variable2) {dothat}
#if ("%1"=@variable3) {dothis instead}}
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
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