|
alaric_tynan Newbie
Joined: 05 Sep 2004 Posts: 8
|
Posted: Sun Sep 05, 2004 3:54 pm
#IF command help |
I am trying to alter a code I have. This is the code:
Code: |
tmp = %ismember( Food-Drink, @cnrContents)
#T+ SleepEat
#if (@tmp="") {#show %ansi( white)You have not have a Food-Drink container option.} {
#if %item( @cnrNames, @tmp)=None {#show %ansi( white)Your Food-Drink container option is not set.} {
#if %item( @cnrLocations, @tmp)=" " {
get @ctlCurrentFood %item( @cnrShortnames, @tmp)
get @ctlCurrentFood %item( @cnrShortnames, @tmp)
eat @ctlCurrentFood
eat @ctlCurrentFood
} {
get %item( @cnrShortnames, @tmp) %item( @cnrLocations, @tmp)
get @ctlCurrentFood %item( @cnrShortnames, @tmp)
get @ctlCurrentFood %item( @cnrShortnames, @tmp)
eat @ctlCurrentFood
eat @ctlCurrentFood
put %item( @cnrShortnames, @tmp) %item( @cnrLocations, @tmp)
}
} |
What I am trying to do is, if I do not need both food items to get full, make it put the extra food back in my container. I figure the #IF command can use some sort of variable or experession to see if this is the case and have the true or false command do it automatically. The messages I get are these.
You eat XXX.
You are no longer hungry.
or
You eat XXX.
You are full.
or
You are too full to eat more. |
|
Last edited by alaric_tynan on Sun Sep 05, 2004 5:31 pm; edited 1 time in total |
|
|
|
geniusclown Magician
Joined: 23 Apr 2003 Posts: 358 Location: USA
|
Posted: Sun Sep 05, 2004 5:19 pm |
I'm not completely sure the details of how this should work, but I do notice a couple of errors in your code.
First off, when using #IF, always enclose the the statement to check in (). That is, instead of
Quote: |
#if @tmp="" {#show %ansi( white)You have not have a Food-Drink container option.} |
use
Quote: |
#IF (@tmp="") {#show %ansi( white)You have not have a Food-Drink container option.} |
Second, this is completely in error:
Quote: |
#if {You are too full to eat more.} {put @ctlCurrentFood %item( @cnrShortnames, @tmp)} {eat @ctlCurrentFood} |
The {} will cause a syntax error, as it should be (), and also "You are too full to eat more." is not a statement that can be true or false - zMUD will see that it is neither 0 nor a null set, and will always decide it's true. I think you want a #TEMP statement in here.
Finally, when you set "tmp = %ismember( Food-Drink, @cnrContents)", if "Food-Drink" is not a member of the list @cnrContents, then @tmp will be 0, not null set, as you have it checking for a few lines later.
Correct these syntax errors, and try it again. If it's still not working, please provide more details such as the erroneous output you get instead of what's expected. |
|
_________________ .geniusclown |
|
|
|
alaric_tynan Newbie
Joined: 05 Sep 2004 Posts: 8
|
Posted: Sun Sep 05, 2004 5:31 pm |
Actually, I missed that second #if you talked about. I was toying around with stuff, I was going to remove that. It wasn't part of the original code. AS for the first one, the code may or may not work, its just for info, not any real use. The code itself works just fine though. I just needed to add to it to make it work, ignore that second if thats completely wrong. My poor attempt at figureing it out myself, that I forgot to remove from my post.
I edited it to be as it should be. I do not really know where to begin with it. I was trying to debate how to make a variable to determine if I get the "you are too full to eat more" message, and have that tell the code which action to take. Understand? |
|
|
|
mr_kent Enchanter
Joined: 10 Oct 2000 Posts: 698
|
Posted: Sun Sep 05, 2004 5:54 pm Re: #IF command help |
Code: |
tmp = %ismember( Food-Drink, @cnrContents)
#T+ SleepEat
#if @tmp="" {#show %ansi( white)You have not have a Food-Drink container option.} {
#if %item( @cnrNames, @tmp)=None {#show %ansi( white)Your Food-Drink container option is not set.} {
#if %item( @cnrLocations, @tmp)=" " {
get @ctlCurrentFood %item( @cnrShortnames, @tmp)
get @ctlCurrentFood %item( @cnrShortnames, @tmp)
eat @ctlCurrentFood
eat @ctlCurrentFood
} {
get %item( @cnrShortnames, @tmp) %item( @cnrLocations, @tmp)
get @ctlCurrentFood %item( @cnrShortnames, @tmp)
get @ctlCurrentFood %item( @cnrShortnames, @tmp)
eat @ctlCurrentFood
#T+ eatTrig
#ALARM +2 {
#T- eatTrig
#IF (@finishedEating) {#VAR finishedEating 0} {
eat @ctlCurrentFood
#VAR finishedEating 0
}
}
put %item( @cnrShortnames, @tmp) %item( @cnrLocations, @tmp)
}
}
|
Add this trigger in the command line.
#TRIGGER "eatTrig" {{You are no longer hungry.|You are full.|You are too full to eat more.}} {put @ctlCurrentFood %item( @cnrShortnames, @tmp);#VAR finishedEating 1} "" {} |
|
|
|
alaric_tynan Newbie
Joined: 05 Sep 2004 Posts: 8
|
Posted: Sun Sep 05, 2004 7:16 pm |
Hmmm...its giving me a syntax error....
|
|
|
|
alaric_tynan Newbie
Joined: 05 Sep 2004 Posts: 8
|
Posted: Sun Sep 05, 2004 8:13 pm |
I got the syntax gone, but its not wanting to put the food back...it just says, put what in what? I'm gonna keep toying with it.
|
|
|
|
Silencer Newbie
Joined: 23 Aug 2004 Posts: 8 Location: Tamworth, Australia
|
Posted: Sun Oct 10, 2004 10:18 am |
You need to define the variables in the script for it to work properly. @ designates a variable call.
|
|
|
|
|
|
|
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
|
|