[Coldstuff] Environment list and recursive locations...

David Clifton coldstuff@cold.org
Fri, 15 Feb 2002 21:32:07 -0500 (EST)


------=_Part_0_6407079.1013826727684
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Just to throw in, MOO doesn't bother, so to speak...people who have like, say, a couch in a room and want people to interact with stuff in the room do one of two things. A) they use virtual seats, like those implemented by rat/Rk on Baymoo...I've seen those all over the place in a modified room class. Or they code a special object for the purposes, and modify such things as the :announce, :announce_all etc on it to output to the room, and the :tell on it, which is called to all things in a room when something is announced, tells the people in the couch or what have you...object interaction can be done similarly, by wrapping get take and such in the room, as the rooms are actually very high in MOO for command interpretation...higher than player, I believe....but it has been a bit, I might be wrong on this. I haven't tested in awhile.

David Clifton





---------------------------------------
Original Email
From: Brandon Gillespie <brandon@roguetrader.com>
Sent: Feb 15, 2002 06:23 PM
To: coldstuff@cold.org
Subject: Re: [Coldstuff] Environment list and recursive locations...



For kicks and grins I am including the code for the two variants...
Perhaps somebody can come up with a faster way of doing #2...

------------ #2 style

@program $foundation._environment2
  arg e;

  return #[[this(),1]];
.
@program $location._environment2() +access=pub
  arg e;
  var o,i;
  e = pass(e);
  for o in (.contents()) {
      if (!dict_contains(e,o)) {
          e = dict_union(e,o._environment2(e));
      }
  }
  return e;
.
@program $located._environment2() +access=pub
  arg e;
  e = dict_union(e, pass(e));
  if (!dict_contains(e, location)) {
      return dict_union(e, location._environment2(e));
  }
  return e;
.
@program $foundation.environment2
  return dict_keys(._environment2(#[]));
.

------------ #3 style

@program $foundation.environment3() +access=pub
  return [];
.
@program $location.environment3() +access=pub
  var o, e;
  e = [this()];

  for o in (.contents()) {
      if (o.has_ancestor($located_location)) {
          e += o.contents();
      }
      e += [o];
  }
  return e;
.
@program $located.environment3() +access=pub
  var o, e;

  return [this()] + setremove(location.environment3(), this());
.

_______________________________________________
Cold-Coldstuff mailing list
Cold-Coldstuff@cold.org
http://web.cold.org/mailman/listinfo/cold-coldstuff


------=_Part_0_6407079.1013826727684--