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
Dyron
Apprentice


Joined: 08 Apr 2004
Posts: 103
Location: USA

PostPosted: Mon Dec 01, 2008 3:46 am   

Ismember question
 
is there a way to do a and statement in a ismember?

Code:
(%ismember( confusion, @afflictions)) and (%ismember( stupidity, @afflictions)) {do this}


something along those lines?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Dec 01, 2008 3:52 am   
 
That's pretty much it, except make sure you preface it with an #IF.

Charneus
Reply with quote
Dyron
Apprentice


Joined: 08 Apr 2004
Posts: 103
Location: USA

PostPosted: Mon Dec 01, 2008 4:04 am   
 
hrmm. .something is wrong with it though.. the AND is bugging it

this is what I got exactly:

Code:
#if (%ismember( confusion, @afflictions)) and (%ismember( stupidity, @afflictions)) {do this}
Reply with quote
Dyron
Apprentice


Joined: 08 Apr 2004
Posts: 103
Location: USA

PostPosted: Mon Dec 01, 2008 4:09 am   
 
Figured it out, thanks a ton
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Dec 01, 2008 10:10 pm   
 
The conditional needs to be completely surrounded by (), which is more of a CMud compatibility thing (unmatched braces will drive you batty in CMud). Regarding each side of the AND equation, inner sets of parentheses are not really needed unless you have a binary operation (ie, a+b).

#if (
%ismember(stuff) and (@a = 12)
) {do this} {else do this}
_________________
EDIT: I didn't like my old signature
Reply with quote
Dyron
Apprentice


Joined: 08 Apr 2004
Posts: 103
Location: USA

PostPosted: Tue Dec 02, 2008 2:56 am   
 
Alright.. need to see how to make this work.


Code:
#IF ((%ismember( @afflictions, @focuslist)) {focus}


basically, if any of the @afflictions are in the @focuslist I want it to focus..
Currently it'll only work if there is only one thing in the afflictions.
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Tue Dec 02, 2008 4:06 am   
 
Ok, thats 2 lists. To do that you'll want to use #FORALL

Code:
#FORALL @afflictions {#IF (%ismember(%i, @focuslist)) {focus}}
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Dec 02, 2008 9:55 am   
 
Though you'll probably want to use a variable to detect the first match (the command is focus;matched=1 rather than just focus and the %ismember check also checks the value of @matched).
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Ralph1971
Wanderer


Joined: 01 Mar 2008
Posts: 64

PostPosted: Thu Dec 04, 2008 4:58 am   
 
would part of his problem be with his original #if statement be he's missing a closing ")"?
Quote:

#IF ((%ismember( @afflictions, @focuslist)) {focus}
_________________
Win7-home - Cmud 3.33a
WinXP-pro - Zmud 7.21
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Dec 04, 2008 10:21 am   
 
That's a good point, actually, I hadn't noticed that. The problem's not that there was one missing at the end, but that there was an extra one at the start. In fact, both of the ones at the end and start aren't needed in this case:

#if %ismember(stuff,stuff) {}

will work just as well.
_________________
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