Container object
This object defines object behavior related to having contents.
Public methods:
contents() Get contents
contains(obj) Determine if object in contents
put(obj) Put object in container
take(obj) Take object from container
Non-overridable calls from $located:
add_sender_to_contents() Add sender to contents
remove_sender_from_contents() Remove sender from contents
Overridable notification calls from $located:
will_arrive(old_place) Notification of impending arrival
will_leave(place) Notification of impending departure
did_arrive(old_place) Notification of completed arrival
did_leave(place) Notification of completed departure
parent vr
object container
var container inited 0
var container contents 0
method init
arg ancestors;
(> pass(ancestors) <);
if (definer() in ancestors)
contents = [];
.
eval
.init(ancestors());
.set_name("Generic container object");
.
method contents
return contents;
.
method contains
arg obj;
return obj in contents ? 1 | 0;
.
method put
arg obj;
obj.move(this());
.
method take
arg obj;
if (!(obj in contents))
throw(~objnf, "Object (" + toliteral(obj) + ") not in contents.");
obj.move(sender());
.
method will_arrive
arg old_place;
if (!caller().is_agent('movement))
throw(~perm, "Caller not an agent of located protocol");
.
method will_leave
arg place;
if (!caller().is_agent('movement))
throw(~perm, "Caller not an agent of located protocol");
.
method did_arrive
arg place;
if (!caller().is_agent('movement))
throw(~perm, "Caller not an agent of located protocol");
.
method did_leave
arg place;
if (!caller().is_agent('movement))
throw(~perm, "Caller not an agent of located protocol");
.
method add_sender_to_contents
disallow_overrides;
if (!caller().is_agent('movement))
throw(~perm, "Caller not an agent of located protocol");
if (sender().location() != this())
throw(~location, "Sorry, but you're not here.");
contents = setadd(contents, sender());
.
method remove_sender_from_contents
disallow_overrides;
if (caller() != $located)
throw(~perm, "Caller not an agent of located protocol");
if (sender().location() == this())
throw(~location, "You're still here.");
contents = setremove(contents, sender());
.