@q
@program goback.muf
1 9999 d
i
( goback.muf    v1.0    Jessy @ FurryMUCK    11/99
  
  Actions linked to this program will return you to the last room
  you were in, provided that, 1, it is still a valid destination,
  and 2, it is not a room specifically excluded from this program
  with the #exclude option.
    
  A typical use for this program would be to allow players to 
  return to an IC location from an OOC area. For example, if
  a Nexus were in an OOC environment room, one could create a 
  'goback' action attached to the OOC environment room, go to the
  OOC environment room, and #exclude it. The result would be that
  when people enter the OOC area, their last IC location is recorded.
  Because the OOC area is #excluded, this location would not be
  over-written as they move around in the OOC area. If they type
  'goback' while in the OOC area, they would be returned to their
  last IC location. The 'goback' command would not be recognized
  in IC rooms.
    
  INSTALLATION:
    
  Set the program Link_OK and Wizard so that it can move with 
  !Jump_OK players and destinations. Link either a global or 
  area-specific command to the program. Set the _depart prop on room
  #0 to trigger the program:
    
    @propset #0=dbref:_depart/goback:<#dbref of program>
           
  Goback.muf may be freely ported. Please comment any changes.
)
  
$define Tell me @ swap notify $enddef
 
: DoHelp  (  --  )                                (* show help screen *)
  
  " " Tell
  prog name " (#" strcat prog intostr strcat ")" strcat Tell 
  " " Tell
  
  "This command sends you back to the last room you were in, provided "
  "(1) it is still a valid destination, and (2) it is not a room "
  "specifically excluded from this program with the #exclude option."
  strcat strcat Tell " " Tell
    
  "  $command .............. Return to last valid room" 
  command @ "$command" subst Tell
  "  $command #exclude ..... Exclude current room and any rooms "
  command @ "$command" subst Tell
  "                          contained by it from this program."
  Tell
  "                          You must control the room."
  "  $command #include ..... Include current room and any rooms "
  command @ "$command" subst Tell
  "                          contained by it for this program."
  Tell
  "                          You must control the room."
  Tell " " Tell
;
 
: DoSendTo  ( d --  )                          (* move user to room d *)
  
  me @ swap moveto
  trig "_/odr" getpropstr if
    me @ location me @
    me @ name " " strcat
    trig "_/odr" getpropstr strcat
    notify_except
  then
; 
  
: main
  
  dup if
    "#help" over stringpfx if                           (* show help? *)
      DoHelp exit
    then
    "#exclude" over stringpfx if                     (* exclude room? *)
      me @ loc @ controls not if 
        "Permission denied." Tell exit
      then
      loc @ "_gbignore" "yes" setprop
      ">>  $command will now ignore this room "
      command @ "$command" subst
      "and any rooms contained in it" strcat 
      Tell exit
    then
    "#include" over stringpfx if                     (* include room? *)
      me @ loc @ controls not if 
        "Permission denied." Tell exit
      then
      loc @ "_gbignore" "yes" setprop
      ">>  $command will record this room "
      command @ "$command" subst
      "and any rooms contained in it" strcat 
      Tell exit
    then
    dup "Depart" smatch if   (* movement triggered... record location *)
      loc @ "_gbignore" envpropstr pop not if     (* unless _gbignore *)
        pop
        loc @ room? not if exit then
        me @ "@/goback"
        loc @ setprop 
      then
    then
  else                                 (* user is trying to goback... *)
    me @ "@/goback" getprop dup if           (* get location and send *)
      dup ok? if
        dup room? if
          DoSendTo 
        then
      else
        ">>  Sorry, the room I'm told to return you to no longer exists."
        Tell pop
      then
    else
      trig "_default" getprop dup if
        DoSendTo 
      else
        pop
      then
    then
  then
;
.
c
q