Generic Container Room (#1016)

(an instance of Generic Room with Seats made by melusina)

     The GCR is both a room and container. You can set opacity, toggle outside listening, and assorted other container-roomlike things. A note of caution: the 'look outside' message needs to be set to "Outside," or else it doesn't work. Sorry. This room also has a look_msg, for handy integration.
     -------
     This child of the PARC allows you to make custom seats of any amount, holding a custom amount of people each. The owner can create seats fitting for their room environment and theme. See `help #955'.



VERB SOURCE CODE:

p*ut in*sert d*rop:
if ((this.location != player) && (this.location != player.location))
    player:tell("You can't get at ", this.name, ".");
elseif (dobj == $nothing)
    player:tell("What do you want to put ", prepstr, " ", this.name, "?");
elseif ($command_utils:object_match_failed(dobj, dobjstr))
elseif ((dobj.location != player) && (dobj.location != player.location))
    player:tell("You don't have ", dobj.name, ".");
elseif (!this.opened)
    player:tell(this.name, " is closed.");
else
    set_task_perms(callers() ? caller_perms() | player);
    dobj:moveto(this);
    if (dobj.location == this)
        player:tell(this:put_msg());
        if (msg = this:oput_msg())
            player.location:announce(player.name, " ", msg);
        endif
    else
        player:tell(this:put_fail_msg());
        if (msg = this:oput_fail_msg())
            player.location:announce(player.name, " ", msg);
        endif
    endif
endif
.


re*move ta*ke g*et:
if (!this.opened)
    player:tell(this.name, " is not open.");
elseif (this.dark)
    player:tell("You can't see into ", this.name, " to remove anything.");
elseif ((dobj = this:match_object(dobjstr)) == $nothing)
    player:tell("What do you want to take from ", this.name, "?");
elseif ($command_utils:object_match_failed(dobj, dobjstr))
elseif (!(dobj in this:contents()))
    player:tell(dobj.name, " isn't in ", this.name, ".");
else
    dobj:moveto(player);
    if (dobj.location == player)
        player:tell(this:remove_msg());
        if (msg = this:oremove_msg())
            player.location:announce(player.name, " ", msg);
        endif
    else
        dobj:moveto(this.location);
        if (dobj.location == this.location)
            player:tell(this:remove_msg());
            if (msg = this:oremove_msg())
                player.location:announce(player.name, " ", msg);
            endif
            player:tell("You can't pick up ", dobj.name, ", so it tumbles onto the 
floor.");
        else
            player:tell(this:remove_fail_msg());
            if (msg = this:oremove_fail_msg())
                player.location:announce(player.name, " ", msg);
            endif
        endif
    endif
endif
.


open:
if (this.opened)
    player:tell("It's already open.");
    "elseif (this:is_openable_by(player))";
elseif (this:is_openable_by(callers() ? caller_perms() | player))
    this:set_opened(1);
    player:tell(this:open_msg());
    if (msg = this:oopen_msg())
        player.location:announce(player.name, " ", msg);
    endif
else
    player:tell(this:open_fail_msg());
    if (msg = this:oopen_fail_msg())
        player.location:announce(player.name, " ", msg);
    endif
endif
.


@lock_for_open:
set_task_perms(player);
key = $lock_utils:parse_keyexp(iobjstr, player);
if (typeof(key) == STR)
    player:tell("That key expression is malformed:");
    player:tell("  ", key);
else
    res = this.open_key = key;
    if (typeof(res) == ERR)
        player:tell(res, ".");
    else
        player:tell("Locked opening of ", this.name, " with this key:");
        player:tell("  ", $lock_utils:unparse_key(key));
    endif
endif
.


is_openable_by:
return (this.open_key == 0) || $lock_utils:eval_key(this.open_key, args[1]);
.


close:
if (!this.opened)
    player:tell("It's already closed.");
else
    this:set_opened(0);
    player:tell(this:close_msg());
    if (msg = this:oclose_msg())
        player.location:announce(player.name, " ", msg);
    endif
endif
.


@unlock_for_open:
set_task_perms(player);
res = dobj.open_key = 0;
if (typeof(res) == ERR)
    player:tell(res, ">");
else
    player:tell("Unlocked ", dobj.name, " for opening.");
endif
.


tell_contents:
pass(@args);
if ((msg = this:empty_msg()) && (this.contents == {}))
    player:tell(msg);
endif
.


set_opened:
if (!$perm_utils:controls(caller.owner, this))
    return E_PERM;
else
    this.opened = opened = !(!args[1]);
    this.dark = this.opaque > opened;
    return opened;
endif
.


@opacity:
if (!$perm_utils:controls(player, this))
    player:tell("Can't set opacity of something you don't own, now can you?");
elseif ((iobjstr != "0") && (!tonum(iobjstr)))
    player:tell("Opacity must be an integer (0, 1, 2).");
else
    player:tell("Opacity changed:  Now " + {"transparent.", "opaque.", "a black hole."}[1 
+ this:set_opaque(tonum(iobjstr))]);
endif
.


set_opaque:
if (!$perm_utils:controls(caller.owner, this))
    return E_PERM;
elseif (typeof(number = args[1]) != NUM)
    return E_INVARG;
else
    number = (number < 0) ? 0 | ((number > 2) ? 2 | number);
    this.dark = number > this.opened;
    return this.opaque = number;
endif
.


enter:
if (!this.opened)
    player:tell(this:oput_fail_msg() || (this.name + " is closed."));
else
    loc = player.location;
    if (loc == this)
        player:tell("You're already inside ", this:title(), ".");
    else
        if (this:accept(player))
            player:tell(this:arrive_succeeded_msg() || (("You enter " + this:title()) 
+ "."));
            player:moveto(this);
            fail = 0;
        else
            fail = 1;
        endif
        this:announce(player.name + " ", this:oarrive_succeeded_msg() || "enters.");
        loc:announce_all_but({this}, player.name + " ", this:arrive_outside_msg() 
|| (("disappears into " + this.name) + "."));
    endif
    if (fail)
        player:tell(this:arrive_failed_msg() || (("Unfortunately, " + this:title()) 
+ " doesn't let you enter."));
        if (omsg = this:oarrive_failed_msg())
            loc:announce(player:title(), " ", omsg);
        endif
    endif
endif
.


description:
if (player.location == this)
    return this:inside_description(@args);
else
    return pass(@args);
endif
.


oclose_msg close_msg oopen_msg open_msg oput_fail_msg put_fail_msg oremove_fail_msg oremove_msg remove_fail_msg remove_msg oput_msg put_msg oopen_fail_msg empty_msg arrive_failed_msg oarrive_failed_msg arrive_succeeded_msg oarrive_succeeded_msg arrive_outside_msg leave_succeeded_msg oleave_succeeded_msg leave_outside_msg leave_failed_msg oleave_failed_msg:
msg = this.(verb);
return msg ? $string_utils:pronoun_sub(msg, @args) | "";
.


exit leave out:
if ((loc = this.location) == $nothing)
    player:tell("There's nothing out there.");
    return;
endif
if (player.location == this)
    if (loc:accept(player))
        player:tell(this:leave_succeeded_msg() || "You exit.");
        player:moveto(loc);
        fail = 0;
    else
        fail = 1;
    endif
    if (player.location != loc)
        fail = 1;
    else
        this:announce(player.name + " ", this:oleave_succeeded_msg() || "vanishes.");
        loc:announce_all_but({this, player}, player.name + " ", this:leave_outside_msg() 
|| (("appears after exiting " + this.name) + "."));
    endif
    if (fail)
        player:tell(this:leave_failed_msg() || "You can't seem to leave.");
        if (msg = this:oleave_failed_msg())
            this:announce(player.name + " ", msg);
        endif
    endif
else
    player:tell("You're not in ", this.name, ".");
endif
.


inside_description:
return this.inside_description;
.


set_inside_description:
if (!(caller == this))
    return E_PERM;
elseif (typeof(desc = args[1]) in {LIST, STR})
    this.inside_description = desc;
else
    return E_TYPE;
endif
.


yell:
"Yell -- yells a message to the outside world.";
stuff = "";
if (player.location == this)
    if (this.location == $nothing)
        stuff = "For some reason, nobody outside seems to hear.";
    else
        this.location:announce_all_but({this}, player.name, " yells from inside ", 
this.name, ", \"", argstr, "\"");
    endif
    player:tell("You yell, \"", argstr, "\"");
    this:announce(player.name, " yell, \"", argstr, "\"");
    if (stuff)
        this:announce_all(stuff);
    endif
endif
.


@listen:
"@listen -- enables the container room to hear the outside environment.";
"possible arguments: \"on\" or \"off\"";
choices = {"on", "off"};
if (!argstr)
    player:tell("Listen is currently ", this.listen, ".");
    return;
endif
if (!(argstr in choices))
    player:tell("Usage:  @listen on|off");
else
    this.listen = argstr;
    player:tell("Listen is now ", this.listen, ".");
endif
.


@describe_inside:
if ($perm_utils:controls(player, this))
    this:set_inside_description(iobjstr);
    player:tell("Interior description set.");
else
    player:tell("Only the owner may modify the interior description.");
endif
.


l*ook:
name = this:outside_msg();
if (((!prepstr) && (dobj == $failed_match)) && index(name, dobjstr))
    this:look_outside();
else
    pass(@args);
endif
.


location:
if (!valid(this.location))
    return $nothing;
elseif (is_player(this.location))
    return this.location.location;
else
    return this.location;
endif
.


look_outside:
if (args)
    player = args[1];
endif
player:tell("");
player:tell($string_utils:capitalize(this:outside_msg() + " "), this.name, ", you 
see:");
player:tell("");
where = this.location;
if (where == $nothing)
    player:tell(this:("$nothing_msg")());
    return;
endif
if ((loc = this:location()) != where)
    player:tell(where:title(), " holding ", this:title(), " in...");
endif
if (args)
    player:tell_lines(where:title());
    player:tell_lines(where:description());
else
    loc:look_self();
endif
.


announce_move:
from = args[1];
to = args[2];
this:announce_all(this:teleport_msg() || (this.name + "moves."));
if (room = $object_utils:isa(to, $room))
    for person in (this.contents)
        if (is_player(person))
            this:look_outside(person);
        endif
    endfor
endif
if (!(callers()[2][2] in this.silent_actions))
    speak = $object_utils:isa(from, $room) ? "announce_all" | "tell";
    if (msg = this:teleport_outside_msg(from))
        from:(speak)(msg);
    endif
    speak = room ? "announce_all" | "tell";
    if (msg = this:oteleport_outside_msg(to))
        msg = index(msg, this.name) ? msg | ((this.name + " ") + msg);
        to:(speak)(msg);
    endif
endif
.


tell:
if (this.listen != "off")
    this:announce_all("Outside:", tostr(@args));
endif
.


look_self:
player:tell(this:title());
if (!(args && args[1]))
    desc = this:description();
    if (desc)
        player:tell_lines(desc);
    else
        player:tell("You see nothing special.");
    endif
    if (!this.dark)
        if (player.location != this)
            player:tell(this:inside_description());
        endif
        this:tell_contents(setremove(this:contents(), player), this.ctype);
        this:tell_exits();
    endif
endif
.


outside_msg:
"Copied from Generic Journeying SPARC (#1066):outside_msg by genna (#352) Fri May 
 6 02:56:11 1994 EDT";
return this.(verb);
.



PROPERTY DATA:
      oclose_msg
      close_msg
      oopen_msg
      open_msg
      oput_fail_msg
      put_fail_msg
      oremove_fail_msg
      oremove_msg
      remove_fail_msg
      remove_msg
      oput_msg
      put_msg
      oopen_fail_msg
      open_fail_msg
      empty_msg
      opaque
      opened
      tell_contents
      inside_description
      open_key
      arrive_failed_msg
      arrive_succeeded_msg
      oarrive_failed_msg
      arrive_outside_msg
      oarrive_succeeded_msg
      leave_outside_msg
      leave_failed_msg
      leave_succeeded_msg
      oleave_succeeded_msg
      oleave_failed_msg
      listen
      outside_msg
      look_msg

CHILDREN:
a large glass tank Generic Journeying SPARC Dinghy Left Stall a bathtub Toadstool