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


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Sun Mar 01, 2009 5:26 pm   

Macro Help
 
I can not seem to figure out how to get this working

I have a variable called @cond
I add to this with triggers the afflictions I get eg additem cond clumsy

ok so now I want to do something like this

IF @cond clumsy quaff1
if @cond disloyal quaff2

etc
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Mar 01, 2009 6:22 pm   
 
The functions and commands your are looking for are #IF and %item.
#IF (%item(@cond,1)="clumsy") {quaff1}

The problem you are likely to have is that the solution to one condition will not be mutually exclusive to another condition. For example clumsy and disloyal block each other because they both use drinking, but asdf uses eating. In order to handle this properly you have to look at which tasks you can do first, then which item in the list can be solved through that method. Some further command and functions to look at are #SWITCH and %ismember.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Sun Mar 01, 2009 7:50 pm   
 
ok did as above but i only seem to quaff1 and not any others

I have this so far

#IF (%item(@diag004,1)="clumsy") {quaff1}
#IF (%item(@diag004,1)="resist") {quaff2}
#IF (%item(@diag004,1)="disloyal") {quaff3}

i have tried with 1 two and 3 ailments in variable diag004 but only seems to quaff 1 potion where in fact i should b able to quaff all 3

my diag004 variable look like clumsy|resist|disloyal these are removed when cured so can be any combination
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Mar 01, 2009 8:50 pm   
 
You need to use %ismember, then. %item(blah,1) checks the first item of the list only. You want:

#if %ismember("clumsy",@diag004) {quaff1}
etc
_________________
Rorso's syntax colouriser.

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


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Sun Mar 01, 2009 11:13 pm   
 
thanks Fang
ok 2nd stage in my stuff
I have the above working and it cures all or none dependent if the 4 or 5 conditions are in the variable

ok for another variable @diag008 I want to only cure first off the list and then delitem it as I can not take cures of this type together

so if @diag008 has stuff1|stuff2|stuff3|stuff4 in it how do i nest the command to run through them eg

IF @diag008 stuff1 {eat herb1} if not @diag008 stuff2 {eat herb2} etc I tried reading nested but got confused with brackets etc
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Mar 01, 2009 11:35 pm   
 
Nesting a bunch of #ifs is the only way to do it, really. It's something that's addressed in CMUD with the new #switch command.
_________________
Rorso's syntax colouriser.

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


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Sun Mar 01, 2009 11:45 pm   
 
can i do it in zmud as i really find zmud easier to understand at my low programming level
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Sun Mar 01, 2009 11:58 pm   
 
is it something like this

#if %ismember("stuff1",@diag008) {eat herb1} {#if %ismember("stuff2",@diag008) {eat herb2} {#if %ismember("stuff3",@diag008) {eat herb3}}
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Mar 02, 2009 12:05 am   
 
Yes, but you need to remember to close all the brackets that you open - you're missing a } at the end there. You'll perhaps find it easier if you put the closing bracket with the opening one. So you start by typing:

#if %ismember("stuff1",@diag008) {eat herb1} {}

then you fill in the {}:

#if %ismember("stuff1",@diag008) {eat herb1} {#if %ismember("stuff2",@diag008) {eat herb2} {}}

Then you fill in the final {}:

#if %ismember("stuff1",@diag008) {eat herb1} {#if %ismember("stuff2",@diag008) {eat herb2} {#if %ismember("stuff3",@diag008) {eat herb3}}}

That way you're sure you've closed any {}s that you've opened. I've colour-coded the three #ifs above to make it easier to tell the difference.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)

Last edited by Fang Xianfu on Mon Mar 02, 2009 12:08 am; edited 2 times in total
Reply with quote
stark62
Wanderer


Joined: 04 Apr 2003
Posts: 94
Location: United Kingdom

PostPosted: Mon Mar 02, 2009 12:06 am   
 
thanks your awesome
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Mar 02, 2009 12:08 am   
 
I made a change to the above post, adding some colours to make it easier to understand, if that helps.
_________________
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