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
bebamedo
Novice


Joined: 02 Aug 2006
Posts: 32

PostPosted: Sat Sep 22, 2007 2:50 pm   

matching of string variables
 
I have problem with matching 2 values of 2 string variables. Here is trigger:
#TRIGGER {(%w)'s body ceases to move as his body stiffens into paralysis.} {#VAR Combat/Enemy/afflictions/a %1;#IF (@tar = @a) {#VAR Combat/Enemy/afflictions/eparalised 1}}
I also tried
#TRIGGER {(%w)'s right leg suddenly goes limp} {#VAR Combat/Enemy/afflictions/a %1;#IF (@tar =~ @a) {#VAR Combat/Enemy/afflictions/erightlegmaiden 1}}

Any help would be appreciated.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Sep 22, 2007 3:01 pm   
 
What's the value of the @tar variable? A string list?

If that's the case, a simple = won't work, because @a isn't a matching string list.

The =~ operator tries to match what's before it with a pattern that's after it. The pattern should be a normal zScript trigger pattern. You could try (@a =~ "{@tar}") - I don't have zMUD installed on this computer, so I can't check if that'll properly expand @tar. You might also try (@a =~ %concat("{",@tar,"}")), which should definitely work.

There's also a function designed for this purpose - %ismember. You could use #if %ismember(@a,@tar) if you wanted, too.

Also, why are you using @a at all? In this script, you could just use %1 instead and it'd be faster than constantly reading the value of the variable. If you just use it as a dummy variable, you can probably remove it - if you use it for other things, it might be best to give it a more descriptive name.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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