|
Murdlih Beginner
Joined: 17 Dec 2001 Posts: 24 Location: USA
|
Posted: Mon Dec 24, 2001 7:57 am
Lots of conditions |
It is me again. This time I am trying to keep track of fleeing and reentering places.
So, what I have now is a long list of nested #if's that will work (I messed the {} up a bit) but it is not very pretty or nice. Is there a better way to do this?
In case I wasn't clear enough, when I get the message
"You flee to the north"
fleedir = north, and reenter = south etc. |
|
|
|
undergod Wanderer
Joined: 27 Jun 2001 Posts: 82
|
Posted: Mon Dec 24, 2001 8:12 am |
You could try doing something like this:
#IF (@fleedir == north AND @reenter == south) {blah blah}
But, that would only match if all the conditions were met. It would NOT match if one of the condidions was not met. |
|
|
|
Murdlih Beginner
Joined: 17 Dec 2001 Posts: 24 Location: USA
|
Posted: Mon Dec 24, 2001 8:35 am |
reply yeah. well, I am actually setting reeneter.
*****
You flee to the (%w)
fleedir = %1
fled = 1
#if (@fleedir = north) {reenter = south} {#if (@fleedir = northeast) {reenter = southwest} {#if (@fleedir = east) {reenter = west} {#if (@fleedir = southeast) {reenter = northwest} {#if (@fleedir = south) {reenter = north} {#if (@fleedir = southwest) {reenter = northeast} {#if (@fleedir = west) {reenter = east} {#if (@fleedir = northwest) {reenter = southeast}}}}}}}}
hp;heal
*****
just looking for a prettier way of doing that. but it is no big deal. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Mon Dec 24, 2001 12:15 pm |
You could also try this:
#VAR dirs {north|northeast|east|southeast|south|southwest|west|northwest}
Then the trigger:
You flee to the (%w)
fleedir = %1
fled = 1
#VAR reenter %case(%ismember(@fleedir, @dirs), "south", "southwest", "west", "northwest", "north", "northeast", "east", "southwest")
hp
heal
Kjata |
|
|
|
Murdlih Beginner
Joined: 17 Dec 2001 Posts: 24 Location: USA
|
Posted: Mon Dec 24, 2001 12:17 pm |
thanks. that seems more elegant to me. :)
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Dec 24, 2001 6:14 pm |
Yet another way:
#VAR dirs {up|north|northeast|east|southeast|down|south|southwest|west|northwest}
Trigger:
You flee to the (%w)
Value:
fleedir = %1
fled = 1
#IF (%ismember(%1,@dirs) < 6)) {#VAR reenter %item(@dirs,%ismember(%1,@dirs)+5)} {#VAR reenter %item(@dirs,%ismember(%1,@dirs)-5)}
hp
heal
LightBulb |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon Dec 24, 2001 9:34 pm |
Yet another way to avoid the else chain in this case is a self inverting list
#VAR dirs {|up|north|east|northeast|northwest|southeast|southwest|west|south|down||}
skipping along:
reenter=%item(@dirs,%eval(%numitems(@dirs)-%ismember(@fleedir,@dirs)))
The null items are to balance the math since counting should always start at 0 and to provide that item 1 is null so that you dont get an erronious direction.
%item("dog|cat|rat",0) currently returns dog, %case(0,"dog","cat","rat") though returns null correctly. So if you use Lightbulbs be aware that if the mud should ever respond with something that isn't in dirs you have reenter set to up most likely incorrectly. |
|
|
|
|
|