generic exit (#7)

(an instance of Root Class made by The_Mayor)




VERB SOURCE CODE:

invoke:
this:move(player);
.


move:
"Copied from generic exit (#7):move(new) by Haakon (#2) Sat Aug 14 12:54:22 1993 
PDT";
"Copied from generic exit (#7):move by Haakon (#2) Sat Aug 14 12:43:38 1993 PDT";
what = args[1];
"if (what.location != this.source)";
"  player:tell(\"You can't go that way.\")";
"  return";
"endif";
unlocked = this:is_unlocked_for(what);
if (unlocked)
    this.dest:bless_for_entry(what);
endif
if (unlocked && this.dest:acceptable(what))
    start = what.location;
    if (msg = this:leave_msg(what))
        what:tell_lines(msg);
    endif
    what:moveto(this.dest);
    if (what.location != start)
        "Don't print oleave messages if WHAT didn't actually go anywhere...";
        this:announce_msg(start, what, (this:oleave_msg(what) || this:defaulting_oleave_msg(what)) 
|| "has left.");
    endif
    if (what.location == this.dest)
        "Don't print arrive messages if WHAT didn't really end up there...";
        if (msg = this:arrive_msg(what))
            what:tell_lines(msg);
        endif
        this:announce_msg(what.location, what, this:oarrive_msg(what) || "has arrived.");
    endif
else
    if (msg = this:nogo_msg(what))
        what:tell_lines(msg);
    else
        what:tell("You can't go that way.");
    endif
    if (msg = this:onogo_msg(what))
        this:announce_msg(what.location, what, msg);
    endif
endif
.


recycle:
if ((caller == this) || $perm_utils:controls(caller_perms(), this))
    "... relies on -d...";
    this.source:remove_exit(this);
    this.dest:remove_entrance(this);
    return pass(@args);
else
    return E_PERM;
endif
.


leave_msg oleave_msg arrive_msg oarrive_msg nogo_msg onogo_msg:
msg = this.(verb);
return msg ? $string_utils:pronoun_sub(msg, @args) | "";
.


set_name:
if ($perm_utils:controls(cp = caller_perms(), this) || (valid(this.source) && (this.source.owner 
== cp)))
    return (typeof(e = this.name = args[1]) != ERR) || e;
else
    return E_PERM;
endif
.


set_aliases:
if ($perm_utils:controls(cp = caller_perms(), this) || (valid(this.source) && (this.source.owner 
== cp)))
    if (typeof(e = this.aliases = args[1]) == ERR)
        return e;
    else
        return 1;
    endif
else
    return E_PERM;
endif
.


announce_all_but:
"This is intended to be called only by exits, for announcing various oxxx messages. 
 First argument is room to announce in.  Second argument is as in $room:announce_all_but's 
first arg, who not to announce to.  Rest args are what to say.  If the final arg 
is a list, prepends all the other rest args to the first line and emits the lines 
separately.";
where = args[1];
whobut = args[2];
nargs = length(args);
last = args[nargs];
if (typeof(last) == LIST)
    where:announce_all_but(whobut, @args[3..nargs - 1], last[1]);
    for line in (last[2..length(last)])
        where:announce_all_but(whobut, line);
    endfor
else
    where:announce_all_but(@args[3..nargs]);
endif
.


defaulting_oleave_msg:
for k in ({this.name, @this.aliases})
    if (k in {"east", "west", "south", "north", "northeast", "southeast", "southwest", 
"northwest", "out", "up", "down", "nw", "sw", "ne", "se", "in"})
        return ("goes " + k) + ".";
    elseif (k in {"leave", "out", "exit"})
        return "leaves";
    endif
endfor
if ((index(this.name, "an ") == 1) || (index(this.name, "a ") == 1))
    return ("leaves for " + this.name) + ".";
else
    return ("leaves for the " + this.name) + ".";
endif
.


moveto:
if ((caller in {this, this.owner}) || $perm_utils:controls(caller_perms(), this))
    return pass(@args);
else
    return E_PERM;
endif
.


examine_key:
"examine_key(examiner)";
"return a list of strings to be told to the player, indicating what the key on this 
type of object means, and what this object's key is set to.";
"the default will only tell the key to a wizard or this object's owner.";
who = args[1];
if (((caller == this) && $perm_utils:controls(who, this)) && (this.key != 0))
    return {tostr(this:title(), " will only transport objects matching this key:"), 
tostr("  ", $lock_utils:unparse_key(this.key))};
endif
.


announce_msg:
":announce_msg(place, what, msg)";
"  announce msg in place (except to what). Prepend with what:title if it isn't part 
of the string";
msg = args[3];
what = args[2];
title = what:titlec();
if (!$string_utils:index_delimited(msg, title))
    msg = tostr(title, " ", msg);
endif
args[1]:announce_all_but({what}, msg);
.


look_msg:
"returns .look_msg with this additional substitutions besides regular pronouns:";
"  %dest - substituted for the exit's destination name";
"  %source - substituted for the exit's source name";
return $string_utils:pronoun_sub($string_utils:substitute(this.(verb), {{"%source", 
this.source:title()}, {"%dest", this.dest:title()}}));
.


obvious:
return this.obvious;
.



PROPERTY DATA:
      obvious
      source
      dest
      nogo_msg
      onogo_msg
      arrive_msg
      oarrive_msg
      oleave_msg
      leave_msg
      look_msg

CHILDREN:
bridge west east west east north south west northwest southeast jump north jump open up down east west stairs stairs out southeast nw north south north south north south northwest southeast north south east west west east up elevator east west northeast southwest nw se north south south north down up up down west east north south east west north south east west west east south north up down down up s n west south north east west north south south north down up e w s n west east west east up down north south north back east west west east east west chant back east southeast north up down Generic Breakable Exit north south north south south north south east west nw se out truck north east west west east east west up down east west north south up down north south northeast southwest north south east west north south southeast northwest north south south north east west east west north east south west northwest north north north north north north north north north north north north north north north north north north north north north north up down southwest northeast south north east west north south Taxi Exit Taxi Entrance west east east west east west east west north south south north east west north south south north west east west east east west east west east west north south Library Parlour Disciple's Kitchen Dining Ave east west northwest east southwest east veranda east east north south north south south north east east east east east east north south north south west northwest southeast stage theater backstage stage Enter Exit northeast southwest w e theater w e e nw se office out north south east west northwest southeast outside theater northeast Screen Door southeast street lot Generic Post-Apocalypse Exit northwest south northwest gate east south north north south up down down up east west down up west east north south west gate east west step hut out northeast next next next next north south north south east west up down east south north west east south north south north west east west east west east west east west sw w e ne sw ne sw o enter w e north south north south east north south east up down separation combination ne w n s carnival an ancient statue of Icarus up sw eye mouth up northeast southwest east west enter back up down grey door grey door trash brown door brown door Falltuer south north out southeast down Woody south north south north west east ww west north east west north south west east north south south north east west south east west east street Unmarked taxi stairs down grate curtain out west east south north cage up southwest northeast west east dream use topoi next back up back red door black black door curtained archway archway east enter leave Stairs Stairs Door Door elevator elevator elevator white door white door southwest northeast red door down up up down up down west east north south south north south north north north south river south north north BambooCurtain BambooCurtain Hatch Hatch south north down up up down west east east west south north ss nn ss nn west east northwest southeast north south south east west west east north south shower tub out up splash swim pool out swim north south southwest northeast southeast northwest northeast southwest east west north south east west north south south north south north escape east west ww east west coral east south ee south north east north south west north south south north east west south north south north southeast northwest east west east west north south west shelf out south east west down up north south scaffold down enter southeast west east east west north south nn ss ss nn west east gazebo out nn ss jump down enter out sit north south north south west east begger down up water mermaid west east pay jester south north south gypsies fortune west east rob kill magician mime shop north south sca cars down up sea tubs fount jet bub control down splash down climb faces statue ledge path north south pit west east north east south east down down east west east boat west down climb beach down down signs posters west west east east northeast southwest west L&R Tank east west dive climb north south down up north bath rec play down swim splash relax sing backstage east west east west east east west up up west stairs backstage west east pen out out in path path s n oak oak s stare through continue continue in out return return n s east west north south u d d north south south north south up east west up down west east south up down west east south ne sw d u northeast southwest north south north mouth booth exit southeast northeast east west n burn enough southwest northeast east west Tibet Lotus down up nw east north south east west up door down down east NorthEase enter out nibble mirror back back NorthWest South South North North Ease SouthEast East north west southeast west east west east northwest southeast north south west east southeast northwest d u south out in w e d u ne sw enter out east