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
Eyeless
Wanderer


Joined: 02 Dec 2001
Posts: 80
Location: Canada

PostPosted: Tue Aug 28, 2007 1:23 am   

%ismember
 
#TRIGGER {Your body (*)} {#VAR body {%1}}
#COND {Your spirit feels (*)} {#VAR spirit {%1}}
#COND {You have (*)} {
#VAR wounds {%subchar( "%1", ",!.?:()[]<>", "|")}
#LOOP %numitems( @wounds) {
#VAR currentwound %item( @wounds, 1)
#IF %ismember( @currentwound, @esleftarm) {#VAR Myfreshexternals %additem( @currentwound, @Myfreshexternals)} {#VAR wounds %delitem( @currentwound, @wounds)}
}
}


Variable: wounds an occasional twitching in the neck| some tiny scars across the left arm|some tiny scars across the left eye| a small skin rash| a few nearly invisible scars along the skin

Variable: esleftarm some tiny scars across the left arm|minor scarring along the left arm|severe scarring along the left arm|severe scarring and ugly gashes about the left arm|severe scarring and chunks of flesh missing from the left arm|a severely scarred, mangled and malformed left arm|an ugly flesh stump for a left arm


Variable: Myfreshexternals

I am doing something wrong. I assume it is with %ismember, I tried it with %pos too, neither work. My guess is you cannot check a string of variables against a string. Any suggestions?

Also, can you add multiple variables to %ismember...

eg: %ismember( abc, @yes OR @no OR @maybe)
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Aug 28, 2007 1:27 am   
 
You're right, your use of %ismember is wrong. The easiest way to do this kind of comparison is with #forall:

match=""
#forall @listone {#if %ismember(%i,@listtwo) {match=%i;#abort}}

I've also moved your post to the zMUD discussion forum, since this forum is for completed scripts you want to share with the public.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Aug 28, 2007 4:37 am   
 
It looks like part of your problem is with the line "#VAR currentwound %item( @wounds, 1)", as that won't change at all with the loop. The correct version of that line is "#VAR currentwound %item( @wounds, %i)", but #FORALL is still a better way to handle this.

You will also have a problem with the item in @esleftarm of "a severely scarred, mangled and malformed left arm". The use of %subchar eliminates commas and that particular item contains a comma so it will never be able to match.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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