LPMuds.net
February 09, 2010, 12:54:45 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: This is the forum page. For the main LPMuds page, visit http://lpmuds.net
 
   Home   SITE FAQ INTERMUD DOWNLOADS LINKS Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Changing exit commands  (Read 1191 times)
Ptah
Acquaintance
*
Offline Offline

Posts: 9


View Profile
« on: August 26, 2008, 03:41:58 PM »

I have a need to override exits to do something different than actually move to another room, and one of the methods I attempted was

Code:
int North()
{
    blah blah
    return 1;
}

init()
{
  ::init();
  add_action("North","n");
}

It still fires as "you cannot go in that direction", which implies there is special code that handles directional commands, and I'd still like to not use it if possible, and use mine...
Logged
cratylus
Your favorite and best
Administrator
***
Offline Offline

Posts: 871


Cratylus@Dead Souls <ds> np


View Profile WWW
« Reply #1 on: August 26, 2008, 03:54:52 PM »

Quote
It still fires as "you cannot go in that direction", which implies there is special code that handles directional commands

If you remove the "n" alias from yourself, it should work ok.

-Crat
Logged
daelaskai
BFF
***
Offline Offline

Posts: 164


View Profile
« Reply #2 on: August 26, 2008, 04:15:47 PM »

Removing the "n" alias from yourself would work as Cratylus mentioned
though I think that would be irritating for moving around the rest of the MUD
since the alias would be defined.

I would think you can do the same thing with a pre-exit functional in the
exit.  After using SetExits() to define all of your exits EXCEPT "north", you would
do this:

Code:
AddExit( "north", "/path/to/room/", (: North:));

This has worked for me and there are two examples in stock DS of this being used.

/domains/examples/room/exroom6.c
/domains/examples/room/exroom4.c

Not that Cratylus' idea won't work, this is just a alternative method.

Daelas
Logged
Ptah
Acquaintance
*
Offline Offline

Posts: 9


View Profile
« Reply #3 on: August 26, 2008, 05:23:06 PM »

The functionality I want to do though is basically... spin your heals in one room until you get to the "next" room, by repeated going a direction.

The add_exit doesn't help me there so much.  I wanted to do add_action and then a
Code:
TP->eventMoveLiving(room, s);
when you finally made it.

Removing the alias... that is something I'm not so sure where it resides to evaluate that option.

This functionality is just for this room, btw.
Logged
quixadhal
BFF
***
Offline Offline

Posts: 205



View Profile
« Reply #4 on: August 27, 2008, 03:07:19 PM »

I would think using the pre-exit function is the best way to go.  If they return false (?), it tells the rest of the movement system to cancel the move operation.  Since DS2 is based from DS and thus Nightmare, I assume it has all the pre/post exit and enterance functions?

It was fun, years ago, making an exit that used the pre-exit function to make sure you had a rune of travel, the post-exit to look at the rune and decide which room to send you to, and then the pre-enter function to deny you entry if you weren't high enough level (and also send you somewhere else... can't have you hanging about outside of any rooms, now can we?).

At least I'm pretty sure that was Nightmare... it's been a while. Smiley
Logged

Ptah
Acquaintance
*
Offline Offline

Posts: 9


View Profile
« Reply #5 on: August 28, 2008, 06:04:59 PM »

I guess the issue is I don't really understand where I would implement any of the options mentioned.  pre-exit, removing aliases...

I've been deep in the code for 2 days, and cannot find the first place "north" is set as a capturable command.
Logged
cratylus
Your favorite and best
Administrator
***
Offline Offline

Posts: 871


Cratylus@Dead Souls <ds> np


View Profile WWW
« Reply #6 on: August 28, 2008, 06:09:52 PM »

Quote
I've been deep in the code for 2 days, and cannot find the first place "north" is set as a capturable command.

It isn't.

The verb is "go". 'n' is aliased to "go north"

-Crat
Logged
shigs
Acquaintance
*
Offline Offline

Posts: 37



View Profile
« Reply #7 on: August 28, 2008, 06:11:40 PM »

I guess the issue is I don't really understand where I would implement any of the options mentioned.  pre-exit, removing aliases...

I've been deep in the code for 2 days, and cannot find the first place "north" is set as a capturable command.


As noted before there are two examples in the code.

look at

more /domains/examples/room/exroom6.c

and

more /domains/examples/room/exroom4.c

Both examples are heavily commented and show you exactly how you'd do it.
Logged

daelaskai
BFF
***
Offline Offline

Posts: 164


View Profile
« Reply #8 on: August 28, 2008, 08:01:55 PM »

I guess the issue is I don't really understand where I would implement any of the options mentioned.  pre-exit, removing aliases...

I've been deep in the code for 2 days, and cannot find the first place "north" is set as a capturable command.


As noted before there are two examples in the code.

look at

more /domains/examples/room/exroom6.c

and

more /domains/examples/room/exroom4.c

Both examples are heavily commented and show you exactly how you'd do it.

Yeah.  When I made the example area, I made sure that I commented it
thoroughly to help people understand what I was doing and why.

Daelas
Logged
quixadhal
BFF
***
Offline Offline

Posts: 205



View Profile
« Reply #9 on: August 29, 2008, 04:58:49 AM »

The pre and post exit functions are (were) hooks.  If the function exists in the room, the movement code will call it before (or after) the move happens.  The idea is that you shouldn't HAVE to capture or override anything, as that's inconsistent if different coders do it in different ways.

DS2 does things a little different than I remember, but it's in /domains/examples/room/exroom4.c and is documented in /doc/manual/chapter25.

Essentially, you add functions as closures when you use AddExit(), rather than having the move code look for the function itself.... same result, but more explicit.

Soooo... if you want "north" to only work when some condition is met you would add a pre-exit function to the addexit() call for the north exit, and that function would return false unless your condition is met, then it returns true.  The movement code should call the function whenever anyone tries to use the exit, and if a false is returned, it won't do the move.

Someone who is actually using the mudlib might want to clarify or correct me here... I'm going from skimming the docs. Smiley
Logged

Ptah
Acquaintance
*
Offline Offline

Posts: 9


View Profile
« Reply #10 on: August 29, 2008, 07:12:01 PM »

Perfect.

Pre_exit examples covered my situation, thank you very much.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!