>2) I want to have an actor who takes anything dropped on the ground in
>certain locations. Unfortunately, there are always going to be two
>objects in those locations that it shouldn't take: itself, and the
>player. So I can't just do self.location.contents.moveInto(self).
I may be misunderstanding you, but it seems to me that
self.location.contents.moveInto(self);
won't work anyway, because self.location.contents will be a list, not a
single object.
If you give objects that you don't want the actor to take a property (e.g,
donttake), then this code should do it:
klepto = {
local i;
for (i := 1; i <= length(self.location.contents); i++) {
local o;
o := self.location.contents[i];
if (not o.donttake and not o.isIn(self))
o.moveInto(self);
}
}
As you've described it, you'd just have to put
donttake = true
in Me and in the actor itself. This relies on TADS' guarantee that objects
with no definition for a property return nil when asked for the value of
the property. (I.e., donttake will be nil by default in all objects.)
You will have to check that _o_ is not fixed if your contents method
returns non take-able objects as well as take-able items.
Note that you still have potential problems here. If there is an item in
the location that can't be taken by anyone (perhaps because it's enchanted)
your code will still move it into the actor. Dealing with this is a bit
messy with ADV.T; there's a special verGrab method you will have to call as
well. (Look at thing.verGrab.)
WorldClass formalizes this; you'd just call
actor.cantake(obj, location_type, true)
for each object. This would do the work required to see if there's a "line
of taking" (by analogy to line of sight) between the actor and the object.
Dave Baggett
__
dmb@ai.mit.edu ADVENTIONS: Kuul text adventures! Email for a catalog.
"Mr. Price: Please don't try to make things nice! The wrong notes are *right*."
--- Charles Ives (note to copyist on the autograph score of The Fourth of July)