Re: 2 TADS questions
4 Jun 1995 18:49:41 GMT
In article <GDR11.95Jun4160149@stint.cl.cam.ac.uk>,
Gareth Rees <gdr11@cl.cam.ac.uk> wrote:
>David Baggett <dmb@rice-chex.ai.mit.edu> wrote:
>>
>> for (i := 1; i <= length(self.location.contents); i++) {
>> o := self.location.contents[i];
>> if (not o.donttake and not o.isIn(self))
>> o.moveInto(self);
>> }
>
>To my untrained eye (I know no TADS), this code looks somewhat dodgy.
>Won't the call to o.moveInto(self) modify the list
>self.location.contents, so that the code risks missing some items?
I believe you're right, having only recently been messing around with a
"river" object for my TADS contest submission. I think a better way to do
it (I've since changed my method, but it's messier), is
o := length(self.location.contents);
for (i := 1; i < o; ++i)
if (cantake self.location.contents[1])
self.location.contents[1].moveInto(self);
This should, hopefully, move the first object in the room into self, and
repeat that o times.
>--
>Gareth Rees
--
------------------------------------------------+--------------
The Grim Reaper ** scythe@u.washington.edu |
Dan Shiovitz ** shiov@cs.washington.edu | Aude
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Sapere
_Music of the Spheres_ : Coming Nov '95 |
------------------------------------------------+--------------