Contents | Index | < Browse | Browse >

10.5.  Routines

     Standard.adl declares and defines	the  following	Rou-
     tines for use by the ADL programmer:

		  StdInit,
		  Reach,
		  See,
		  Lit,
		  Avail,
		  CheckAvail,
		  Expect,
		  Preact,
		  Looker,
		  Prompter,
		  TakeAct,
		  DropAct,
		  ActAction,
		  SaveSentence,
		  Dwimmer;

     Their use is defined as follows:

     StdInit	   (StdInit actor)  should  be	executed  in
		   START  if the programmer desires that ALL
		   of the default routines be  used.   Actor
		   should   be	 the  name  of	the  primary
		   interactive Actor in	the scenario.

     Reach	   (Reach  object  container)  is  TRUE	  if
		   object  is  contained in container and if
		   the player can reach	the object.   It  is
		   FALSE  otherwise.   Note  that  this	also
		   checks whether  object  is  contained  in
		   something which is contained	in container
		   and so on.

     See	   (See	object container) is TRUE if  object
		   is  contained in container and the player
		   can see the object.	It is  FALSE  other-
		   wise.  This also checks containers inside
		   containers.

     Lit	   (Lit) is TRUE if  something	is  lighting
		   the	player's  location  and	FALSE other-
		   wise.

     Avail	   (Avail object) is TRUE if the player	 can
		   see	object (either in the room or in the
		   player's inventory)	and  can  reach	 the
		   object.  It is FALSE	otherwise.

     CheckAvail	   (CheckAvail)	checks to  see	whether	 the
		   Dobj	 and  Iobj  typed  by the player are
		   available.  If not, an  appropriate	mes-
		   sage	 is  printed  and  ($exit 1) is	per-
		   formed.

     Expect	   Expect is typically called by the  PREACT
		   of  a Verb.	It looks at the	current	sen-
		   tence to see	whether	it is of  acceptable
		   form.    The	 two  parameters  to  Expect
		   define criteria for	acceptability.	 The
		   first  parameter  indicates what types of
		   direct objects  are	acceptable  and	 the
		   second  indicates  what types of indirect
		   objects are acceptable.   Each  parameter
		   consists  of	 one  or  more of the Expect
		   flags $or'd together.   The	flag  NO_OBJ
		   indicates  that  it is acceptable that no
		   object  be  present;	  ONE_OBJ  indicates
		   that	 it is acceptable that one object be
		   present;  MULT_OBJ indicates	that  it  is
		   acceptable	that   multiple	 objects  be
		   present;  STR_OBJ indicates that it's  OK
		   for	the  object(s)	to  be	strings; and
		   PLAIN_OBJ indicates that it's OK for	 the
		   object(s) to	be normal ADL objects.

		   Example:
				{ "take" needs 1 to N Dobjs and	0 or 1 Iobjs }
				take(PREACT) =
					(Expect	($or MULT_OBJ PLAIN_OBJ)
						($or NO_OBJ ONE_OBJ PLAIN_OBJ))
				;
				{ "quit" can accept no objects }
				quit(PREACT) =
					(Expect	 NO_OBJ	 NO_OBJ)
				;
				{ "unlock" needs exactly one Dobj and Iobj }
				unlock(PREACT) =
					(Expect	($or  ONE_OBJ  PLAIN_OBJ)
						($or  ONE_OBJ  PLAIN_OBJ) )
				;
				{ "say"	needs a	string to say and possibly
				  someone to whom to say it }
				say(PREACT) =
					(Expect	($or ONE_OBJ STR_OBJ)
						($or NO_OBJ ONE_OBJ PLAIN_OBJ))
				;



     Preact	   Preact is the standard PREACT for  Verbs.
		   It  checks  to make sure that exactly one
		   plain Direct	Object was  typed  and	that
		   the	Indirect Object	is not a string.  It
		   also	checks to see  whether	all  of	 the
		   named objects are available.

     Looker	   Looker is the  standard  looking  daemon.
		   It is intended to be	executed every turn.
		   To enable this, either of the  statements
		   ($sdem Looker) or (StdInit actor) must be
		   executed (where  actor)  is	the  primary
		   actor).

     Prompter	   Prompter is the standard  prompting	rou-
		   tine.   To  use  it,	either of the state-
		   ments  ($prompt  Prompter)  or   (StdInit
		   actor) must be executed.

     ActAction	   ActAction is	the standard  Actor  action.
		   It checks to	see whether the	Verb "again"
		   or the Object "it" was used and  modifies
		   the	sentences appropriately.  To use it,
		   either  of  the  statements	($setp	 .ME
		   ACTION ActAction) or	(StdInit actor)	must
		   be executed.

     TakeAct	   TakeAct is called by	the  default  action
		   routine  of	the  Verb  "take"  after the
		   ACTION routines  of	all  of	 the  Direct
		   Objects have	been executed.

     DropAct	   DropAct is  similar	to  TakeAct,  except
		   that	 it  is	called by the ACTION routine
		   of "drop".

     SaveSentence  SaveSentence	should be called by the	 ADL
		   programmer if it is desired that the	Verb
		   "again" and the Object "it"	work  as  in
		   ActAction  above.   Looker calls SaveSen-
		   tence every turn.

     Dwimmer	   Dwimmer is the standard DWIMming routine.
		   It  checks  to  see	whether	an ambiguous
		   object could	 possibly  be  the  one	 the
		   player  meant.   To	use Dwimmer, include
		   the	statement  (IF	(Dwimmer  %1)	THEN
		   ($return 1))	in DWIMI and/or	DWIMD.