|
stark62 Wanderer
Joined: 04 Apr 2003 Posts: 94 Location: United Kingdom
|
Posted: 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 |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: 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 |
|
|
|
stark62 Wanderer
Joined: 04 Apr 2003 Posts: 94 Location: United Kingdom
|
Posted: 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 |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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 |
|
|
|
stark62 Wanderer
Joined: 04 Apr 2003 Posts: 94 Location: United Kingdom
|
Posted: 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 |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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.
|
|
|
|
stark62 Wanderer
Joined: 04 Apr 2003 Posts: 94 Location: United Kingdom
|
Posted: 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
|
|
|
|
stark62 Wanderer
Joined: 04 Apr 2003 Posts: 94 Location: United Kingdom
|
Posted: 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}} |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
|
stark62 Wanderer
Joined: 04 Apr 2003 Posts: 94 Location: United Kingdom
|
Posted: Mon Mar 02, 2009 12:06 am |
thanks your awesome
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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.
|
|
|
|
|
|