From: mollems@wkuvx1.bitnet (Molley the Mage)
Newsgroups: rec.games.int-fiction
Subject: Re: TADS: reachable list problems
Date: 19 Nov 92 12:12:29 CST
Organization: Cthulhu 1992 Campaign HQ

In article <Bxy5Hz.GD0@news.cso.uiuc.edu>, amead@s.psych.uiuc.edu (Alan Mead) writes:
> I'm implementing an office; it has a chair, desk and file cabinet.  The
> desk has a drawer and I'm having trouble.
> 
> One problem is I cannot get the reachable list to include the contents of
> of drawer.  I can put AN item into the list, but I cannot do something like:

Unless you're implementing the desk and file cabinet as only reachable
from the chair, which is a nestedroom, there is really no need to
update the reachable list for anything.  The trick is to make the
drawer its own object, a fixeditem,openable that is "part" of the
desk.  The contents of the drawer are only visible if the drawer is
open, and you can force the player to open it by setting the attribute
isopen = nil.
 
> Second problem: I have a files fixeditem located in the file cabinet, but (1)
> the cabinet ldesc lists the contents of the cabinet, even when closed, and (2)
> doesn't count the files object ("The file cabinet is closed.  It is empty.").

If the files are going to be fixed, then you probably have to include
them in your own description of the cabinet.  The way the listcont ()
function handles things is thus:  if it's a fixeditem, it's not listed
as being present.  You could do one of two things:  either 
- make the files a fixeditem and write the ldesc of the cabinet to
print a message about the files if the cabinet is open, or
- make the files a regular item, but make its verDoTake {} negative
for all cases.

I tend to prefer the former approach, because I like my text to be
more flowery and specific to each item than just "The file cabinet is
open.  It contains some files."

The implementation I would use is something like this:

(note that I'm writing this after no sleep, so don't be surprised if
it's really ponderous and inelegant!)

desk : fixeditem
	location = Office
	noun = 'desk'
	sdesc = "desk"
	thedesc = "the desk"
	ldesc = 
	{
	"The desk rests against the far wall of the office. 
	Resting on the desk you can see one of those ubiquitous
	blotters that all corporations give to their employees in
	order to make them feel special.
	\nThe desk has a drawer, which is ";
	if (drawer.isopen) "open."; else "closed.";
	}
	// if the player types "open desk" instead of "open drawer"
	// we can make his life easier by redirecting the command
	// to the drawer itself.
	verDoOpen (actor) = { drawer.verDoOpen (actor); }
	doOpen (actor) = { drawer.doOpen (actor); }
	verDoClose (actor) = { drawer.verDoClose (actor); }
	doClose (actor) = { drawer.doClose (actor); }
;
drawer : fixeditem, openable
	location = Office
	noun = 'drawer'
	sdesc = "drawer"
	thedesc = "the drawer"
	ldesc = 
	{
	"The drawer is an integral part of the desk.  It's a
	brilliant piece of craftsmanship, carefully designed
	to keep the contents in, and everything else out.  The
	drawer is currently";
	if (self.isopen)
		{
		" open";
		if (self.itemcnt)
			{
			", and contains ";
			listcont (self);
			}
		}
	else 
		" closed, doing its job with remarkable
		dedication";
	". ";
	}
	isopen = nil
	// the verDoOpen, doOpen, verDoClose, and doClose actions
	// are all given to us by the OPENABLE class from ADV.T;
	// really, the ldesc I've given here is needlessly fancy.
	// since the drawer is a container, its contents can't be
	// messed around with unless the drawer is open.
;
filecabinet : fixeditem,openable
	location = Office
	noun = 'cabinet'
	adjective = 'file' 'filing'
	sdesc = "filing cabinet"
	thedesc = "the filing cabinet"
	ldesc = 
	{
	"The file cabinet is truly a work of art.  Made of
	hard gray metal, it nonetheless conveys an aura of total
	oneness with itself and with its surroundings.  The cabinet
	is ";
	if (self.isopen) "open, revealing a sheaf of files";
	else "closed";
	". ";
	}
	isopen = nil
	// we don't want the player stuffing things in the cabinet
	// (or maybe we do, if so take this next bit out)
	verIoPutIn (actor) =
	{
		"The cabinet is stuffed with files.  You couldn't
		really get anything else in there.";
	}
;
files : item,readable
	location = cabinet
	noun = 'files'
	sdesc = "files"
	thedesc = "the files"
	adesc = "a bunch of files"
	ldesc = "The files are ordered sequentially, and seem to be 
	the list of jobs that this office has supervised in the past
	two years.  Some of the files bear closer examination."
	readdesc = "One file in particular catches your attention :
	it's a complete accounting of all the illegal drug
	transactions John Q. President has engaged in for the last
	two years.  Places, dates, and times are given, along with
	amount and types of narcotics.  You can't believe Mr.
	President has just got this sucker lying around in a filing
	cabinet, but there you have it."
	verDoTake (actor) =
	{
		"Not a chance.  He'd know it was gone, and then you'd
		be done for.";
	}
;

The reason that I made the FILE an ITEM instead of a FIXEDITEM is so
that when the player examines the room, if the filing cabinet is open
the description will reflect this, saying "it seems that the filing
cabinet contains a bunch of files."  Likewise, if the desk is open and
contains various items, it will say "It seems that the desk contains
(whatever it contains)."

The difference between CONTAINERS and OPENABLES is subtle, but
important: a container can't ever be closed.

I hope this is what you are looking for.

> Thanks.
> 
> -alan mead
--
Sean 
---
M. Sean Molley, CS Department, Western Kentucky University, Bowling Green, KY
RealSpace - (502) 745-4027 |   "When push comes to shove, push and shove."
All flames and other heavy ordnance should be fired at  MOLLEMS@WKUVX1.BITNET