Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Mon Dec 10, 2012 4:55 pm   

exit command
 
is there a way to retrieve the name field (the exit command) for a given exit in a room, similar to %doorname?
_________________
Discord: Shalimarwildcat
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Mon Dec 10, 2012 7:52 pm   
 
You can with the advanced COM interface in CMUDPro:
Code:
%map.GetRoom(id).Exit("direction").Command

As far as I can tell, there's no way with the standard zScript functions.

EDIT: This code is probably the best you can do with standard zScript functions, though it isn't foolproof:
Code:
$destination = %roomlink($id, $direction)
#forall %roomexit($id) {#if (%len(%i) > 1 and %item(%roomportal($id, %i), 2) = $destination) {// %i is likely the name.}}


This wouldn't necessarily work if there's more than one exit to the same room. You could come up with a better way to check if the exit is a normal direction or a custom command than checking the length too, I just threw this together quickly.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Mon Dec 10, 2012 10:49 pm   
 
I tried the zscript method without any results, i assume the #IF failed somehow...
How would i incorperate the COM method into this?

Code:
<trigger type="Command Input" priority="600" trigontrig="false" id="9">
  <pattern>^(%w)$</pattern>
  <value>#IF (%reversedir( %1)) {
  lastDir=%reversedir( %1)
  #if (@hidden) {sneak %1}
  }
</value>
</trigger>


Essentially, i want to tag a 'sneak' to the beginning of any special exits.

On a related note... is there a way to add to the mapper queue by script?
I added sneak east to the east direction (and so on to all the basic cardinal exits), but i don't want to have to add all the 'sneak special' exits as well.
_________________
Discord: Shalimarwildcat
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue Dec 11, 2012 3:15 am   
 
Not sure I understand what you want exactly... something like this?
Code:
#if (%map.CurRoom().Exit(%1).Command) {sneak %1}

That'll send, for example, sneak east if the east exit has a name set.

You can add to the mapper queue with #queue, but that might not be enough, if you don't add the special exits to the mapper too it might not track properly.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Tue Dec 11, 2012 4:33 am   
 
#QUEUE seems to sent the actual command into the system like a path
that is not what i want
i want the mapper to think i have already sent the command, thereby keeping my place on the map correct when the room description pops up


as for the rest, this works
#if (%map.CurRoom().Exit(%1).Command) {sneak %map.CurRoom().Exit(%1).Command} {sneak %1}
_________________
Discord: Shalimarwildcat
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue Dec 11, 2012 5:18 am   
 
You mean just tell the mapper to move you in a certain direction, without adding it to the queue? Something like this should work:
Code:
$destination = %roomlink(, $exit)
#if (!$destination) {$destination = %item(%roomportal(, $exit), 2)}
#te $destination
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Tue Dec 11, 2012 5:22 am   
 
but that overlooks all of my potential #NODIR triggers, just because i send the command doesnt mean i succeed.
_________________
Discord: Shalimarwildcat
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Tue Dec 11, 2012 8:39 am   
 
%roomexit returns the exit list with the "name" field instead of a direction, if it exists, otherwise it uses the direction field. Take note that it returns a string list of directions. It works this way because each time you enter the dummy direction, CMUD substitutes it with the name field. This allows portals and custom exits to work.
Also look at %roomlink and %roomportal. The combined use of these three functions gives you complete information of the exit configuration for a room.
e.g:
Code:

$exits = %roomexit($roomid) // Get the exit list
..
#FORALL $exits {
   $room = %roomlink( $roomid, %i)
   #IF (%null( $room)) {$room = %item( %roomportal( $roomid, %i), 2)}
// $room now contains the id or vnum for the room this exit leads to.
    ...
    ...
}

Above, %i contains either the direction or the contents of the name field.
You will find that both the dummy direction and the name will elicit the same information, which is as expected.
So, play around with it. Just add a named direction to a room and look at the output of the above functions.
Just remember that the %roomexit output will contain the name field as part of the returned stringlist.
_________________
Sic itur ad astra.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Tue Dec 11, 2012 9:41 pm   
 
That part was already handled, but thanks for the input.

Now i just need to figure out how to make the mapper think i have sent the command when sneaking around, so the #LOC stays updated.
_________________
Discord: Shalimarwildcat
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Dec 11, 2012 10:43 pm   
 
check out the #MOVE command.
_________________
EDIT: I didn't like my old signature
Reply with quote
rozdwojeniejazni
Wanderer


Joined: 13 Aug 2011
Posts: 74

PostPosted: Tue Dec 11, 2012 10:45 pm   
 
MattLofton:
shalimar wrote:
but that overlooks all of my potential #NODIR triggers, just because i send the command doesnt mean i succeed.
Reply with quote
rozdwojeniejazni
Wanderer


Joined: 13 Aug 2011
Posts: 74

PostPosted: Tue Dec 11, 2012 11:08 pm   
 
My humble idea would be to create a temporary dir, just before sending your 'sneak $exitname' command. Something like this:
Code:
#dir x %concat("sneak ",$exitname) nw

You could #undir x it later, or probably even better leave it for overwriting.
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Wed Dec 12, 2012 2:03 am   
 
How about using #TELEPORT?
_________________
Sic itur ad astra.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Wed Dec 12, 2012 3:38 am   
 
#TELEPORT and #MOVE both bypass my #NODIR triggers... if i cant spoof the mapper queue, maybe i will just have my #TAG for roomname do a #FIND when i am sneaking
_________________
Discord: Shalimarwildcat
Reply with quote
rozdwojeniejazni
Wanderer


Joined: 13 Aug 2011
Posts: 74

PostPosted: Wed Dec 12, 2012 9:42 am   
 
Did you read my post? As far as I tested it, it should work.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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