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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
itsr0y
Beginner


Joined: 20 Jan 2002
Posts: 25

PostPosted: Sun Jun 20, 2004 4:17 am   

Relative Directions
 
My MUD (Discworld) has some rooms that have relative directions, eg. forward, backward, left, and right (also forward-left and such for diagonals). You can also do turn left, right, or around, which will change the direction you are facing. (You can also 'turn half {left|right}' to do the diagonals). The mud keeps track of what way you're facing, so if you enter a room by typing 'west', typing forward will move you west again, while backward will move you east and change the current direction to east. Another example is you're facing west, you type 'backward' then 'forward' - you'd go east twice.
There are not a lot of rooms like this, but there are a few. You can use the relative directions in any room, though, as far as I know. I set up some mappings to make it easier to traverse and map "relative direction" rooms:
Code:
#CLASS {Relative_Dirs}
#ALIAS dir_relative {
  #VAR temp %eval( %ismember( %1, @dir_list_rel) + %ismember( @dir_forward, @dir_list) - 5)
  #IF (@temp > 8) {#ADD temp -8}
  #IF (@temp < 0) {#ADD temp 8}
  #VAR temp %item( @dir_list, @temp)
  }
#ALIAS dir_turn {
  #VAR temp %eval( %ismember( %1, @dir_list_turn) + %ismember( @dir_forward, @dir_list) - 5)
  #IF (@temp > 8) {#ADD temp -8}
  #IF (@temp < 0) {#ADD temp 8}
  #VAR temp %item( @dir_list, @temp)
  }
#ALIAS add_rel_exit {
  dir_relative {%1}
  #IF (%roomlink( ,@temp) = -1) {#NOOP %roomlink( ,@temp, -2)}
  }
#VAR dir_forward {south}
#VAR dir_list {north|northeast|east|southeast|south|southwest|west|northwest}
#VAR dir_list_abbr {n|ne|e|se|s|sw|w|nw}
#VAR dir_list_rel {backward|backward-left|left|forward-left|forward|forward-right|right|backward-left}
#VAR dir_list_turn {around|UNUSED 1|left|half left|UNUSED 2|half right|right|UNUSED 3}
#ONINPUT {^(@dir_list_rel)$} {
  dir_relative {%1}
  #VAR dir_forward {@temp}
  #MAP {@dir_forward}
  }
#ONINPUT {^turn (@dir_list_turn)$} {
  dir_relative {%1}
  #VAR dir_forward {@temp}
  }
#REGEX {^(@dir_list)$} {#VAR dir_forward {%1}}
#REGEX {^(@dir_list_abbr)$} {#VAR dir_forward {%item( @dir_list, %ismember( %1, @dir_list_abbr))}}
#KEY CTRL-KEY5 {out}
#KEY CTRL-KEY8 {forward}
#KEY CTRL-KEY9 {forward-right}
#KEY CTRL-KEY6 {right}
#KEY CTRL-KEY3 {backward-right}
#KEY CTRL-KEY2 {backward}
#KEY CTRL-KEY1 {backward-left}
#KEY CTRL-KEY4 {left}
#KEY CTRL-KEY7 {forward-left}
#KEY ALT-CTRL-KEY8 {add_rel_exit forward}
#KEY ALT-CTRL-KEY9 {add_rel_exit forward-right}
#KEY ALT-CTRL-KEY6 {add_rel_exit right}
#KEY ALT-CTRL-KEY3 {add_rel_exit backward-right}
#KEY ALT-CTRL-KEY2 {add_rel_exit backward}
#KEY ALT-CTRL-KEY1 {add_rel_exit backward-left}
#KEY ALT-CTRL-KEY4 {add_rel_exit left}
#KEY ALT-CTRL-KEY7 {add_rel_exit forward-left}
#CLASS 0

I don't know if this will be of any use to anyone, but I figured I'd post what I have. Using CTRL-Numpad moves you in that direction and updates the mapper, while CTRL-ALT-Numpad adds an exit stub in that direction (I could have done automatic stub creations using the exit line, but it's not worth the trouble.)

Now, here's my question: Is there any way to tell the mapper that certain rooms are "relative direction" rooms, and to use the relative directions instead of absolute? I mean, I know I can just hit CTRL when I get to certain areas, but it would be nice for the mapper to do it automatically so I can speedwalk through these areas.

I think I can probably set the user-defined string with some flag, and re-bind the normal numpad directions to check for the flag and do either an absolute or relative appropriately. This would be able to turn relative into absolute - e.g. if you press 4, it will either go 'west' or the make an appropriate turn to go west. I would still leave the CTRL bindings as they are. Being that I have a decent sense of direction, I have no problem just using the CTRL bindings so this really wouldn't do me much good - the thing I want is the automapper to do it.

Any ideas?

PS - I know this is a long, long post, and I just figured since i spent the time to set up these scripts, I'd share them and see if anyone has any ideas for improvement. If no one can or feels like making them better, no big deal, but if anyone gets use out of them, great!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Jun 20, 2004 11:00 pm   
 
I would suggest using a flag in the user string of the rooms, and an #ONINPUT {^%t$}. That way you can tie into your current script to update variables, and send relative dirs when needed. You can use #GAG in an oninput to not send the user input, and #SUB to replace it. If done right you should even be able to use speedwalking in slow-mode.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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