Quick Reference for ALAN Standard Library v1.00


This document describes in short how to implement various things in the ALAN interactive fiction language, using
the Standard Library v1.00. Straight examples without much explanation are given. More thorough examples with
detailed explanations are in the library files themselves.


The contents:


LOCATIONS

A basic location
An indoor location
An outdoor location
A dark location
Counting the times a location has been visited
Keeping track of the times the location has been described


OBJECTS

A basic object
A container object
 + listing the contents of a container object after 'inventory'
A background object
 + a background object which is present in many places at once
A piece of clothing
A device
A door
A lightsource
A liquid
A scenery object
A supporter object
 + a combined supporter and container object (e.g. a table with thing on top + drawers inside)
A weapon
A window


ACTORS

A basic actor
A person (e.g. 'a man')
A named person (e.g. 'Mr Brown')
 + changing an unnamed actor to named in mid-game
A following NPC



LOCATIONS
=========


A basic location
=================


THE bedroom ISA LOCATION

	DESCRIPTION "This is your bedroom."

	EXIT east TO closet
		CHECK "The closet is locked."
	END EXIT.

	EXIT north TO bathroom.

END THE.


THE bathroom ISA LOCATION

	DESCRIPTION "This is the bathroom."

	EXIT south TO bedroom.

END THE.



An indoor location
==================


- all ROOMS automatically have a ceiling, walls and a floor.
 

THE inside_shop ISA ROOM
	
	NAME 'In the candy shop'

	DESCRIPTION "Everything here is on sale."

	EXIT out to street_corner.

END THE.



An outdoor location
===================


- all SITES automatically have a ground and a sky.


THE street_corner ISA SITE

	DESCRIPTION "There's a lot of traffic today."

	EXIT east TO inside_shop.

END THE.



A dark location
===============


THE basement ISA DARK_LOCATION

	DESCRIPTION "Only useless junk can be seen lying around."

	EXIT up TO hall.

END THE.

- The description above is shown only when/if the dark location is lighted by any means.
- Otherwise the description is "It is pitch black. You can't see anything at all." This default can be changed
  by editing the Description Check statement given at the dark location class declaration in 'locations.i'.
- If a dark location in your game is never supposed to be lighted, you can leave out any description of your own:


THE basement ISA DARK_LOCATION

	EXIT up TO hall.

END THE.



Counting the times a location has been visited
==============================================


The bedroom IS A ROOM

	DESCRIPTION 
		"This is a tastefully decorated bedroom."
		IF visited OF bedroom = 1  (= this is your first visit in the location)
			THEN "You have never been in this bedroom before."
			ELSE "YOu have been here" SAY visited OF bedroom - 1. "times before."
			      (or just e.g.: "You have been here before.", etc.)
		END IF.

END THE.



Keeping track of the times a location has been described
========================================================


1)

THE bedroom ISA ROOM

	DESCRIPTION
		"This is a tastefully decorated bedroom."
			IF described OF bedroom = 1  (= the first-time description)
				THEN "Sunshine pours in from the window."
				ELSE "Sunshine keeps pouring in from the window." (all subsequent times)
			END IF.

END THE.



2)

THE meadow ISA SITE

	DESCRIPTION
		"Flies and other insects buzz around you"	
		IF described OF meadow > 5
			THEN ", which starts to annoy you little by little"
		END IF.
		"."

END THE.	




OBJECTS
=======



A basic object
===============


THE ball ISA OBJECT AT bedroom

	DESCRIPTION "A red ball lies in the middle of the floor."

	VERB examine 
		DOES ONLY "It is an ordinary red ball."
	END VERB.
	
END THE.




A container object
==================


1)


THE box ISA LISTABLE_CONTAINER IN Room1	
END THE.
	

THE ball ISA OBJECT IN box
END THE.




2) 


THE box ISA LISTABLE_CONTAINER IN Room1 
	
	OPAQUE CONTAINER		= cannot be seen through when closed
	
	IS closeable. IS closed.

END THE.



THE ball ISA OBJECT IN box
END THE.




+ listing contents of a container object after 'inventory':


VERB inventory				( in 'verbs.i')

	DOES
		LIST hero.

		IF box IN hero 		-- !add these lines to the library code
			THEN LIST box.	-- !
		END IF.			-- !

END VERB.





A background object
===================


THE sun ISA BACKGROUND AT garden
END THE.



+ a background object which is present in many places at once:

In the following example, the sun is found in 'garden', 'by_the_pond' and 'crossing_paths:


THE sun ISA background AT garden_area

	DESCRIPTION ""

END THE.


THE garden_area ISA LOCATION
END THE.

THE garden ISA SITE AT garden_area
END THE.

THE by_the_pond ISA SITE AT garden_area
END THE.

THE crossing_paths ISA SITE AT garden_area
END THE.




A piece of clothing:
====================


1) Clothing worn by the player:


THE shirt ISA CLOTHING IN worn

	IS topcover 8.  		-- the value of this attribute must be taken from the clothing table (below)

END THE.



2) Clothing worn by an NPC:
 

THE hat ISA CLOTHING IN mr_brown_worn

	IS headcover 2.

END THE.



THE mr_brown_worn ISA NPC_WORN

	HAS carrier mr_brown.

END THE.



THE mr_brown ISA PERSON IN Room1

	(DESCRIPTION
		LIST mr_brown.
		LIST mr_brown_Worn.)


	VERB examine
		DOES ONLY
			LIST mr_brown.		-- lists what Mr Brown is carrying
			LIST mr_brown_worn.	-- lists what Mr Brown is wearing
	END VERB.


END THE.




-- Clothing 			Headcover	Topcover 	Botcover 	Footcover 	Handcover

-- hat				2		0		0		0		0
-- vest/bra			0		2 		0		0		0
-- undies/panties		0		0		2		0		0
-- teddy			0		4		4		0		0
-- blouse/shirt/T-shirt		0		8		0		0		0
-- dress/coveralls		0		8		32		0		0
-- skirt			0		0		32		0		0
-- trousers/shorts		0		0		16		0		0
-- sweater/pullover		0		16		0		0		0
-- jacket			0		32		0		0		0
-- coat				0		64		64		0		0
-- socks/stockings		0		0		0		2		0
-- tights/pantiehose		0		0		8		2		0
-- shoes/boots			0		0		0		4		0			
-- gloves			0		0		0		0		2




A device
========


THE thingummyjig ISA DEVICE AT lab
END THE.




A door
======


THE white_door ISA DOOR AT lobby
END THE.


- Doors cannot be placed "between rooms" in the game code. Just make them
present in the location. You have to have a similar door object in the other room 
(= where the door is leading) and take care that it is closed/NOT closed properly
in accordance with its counterpart door object. You can also locate one and the same
door object between rooms when the hero moves about.



A liquid
========


1) Liquids that are not in containers (and thus cannot be carried):


THE puddle ISA LIQUID AT road

	NAME puddle NAME muddy water

END THE.



2) Liquids in containers:


THE juice ISA LIQUID IN glass

	HAS vessel glass.

END THE.



THE glass ISA LISTABLE_CONTAINER 
END THE.




A lightsource
=============


1)


THE lamp ISA LIGHTSOURCE AT bedroom
	IS NOT natural.
END THE.


2)


THE match ISA LIGHTSOURCE IN matchbox
END THE.



Lightsource objects are by default natural. A natural lightsource cannot be switched on or off,
only lighted (lit) and extinguished (put out).





A scenery object
================



THE flowerpot ISA SCENERY AT living_room
END THE.




A supporter object
==================


THE table ISA SUPPORTER AT living_room
END THE.



THE coffee_cup ISA OBJECT IN table			-- note the 'IN' here

	NAME 'coffee cup'

END THE.



+ combined supporter and container objects:


In the following example, a table has both a cup on it and a drawer in it:



THE table ISA SUPPORTER AT living_room
	HAS component {drawer}.

	VERB examine
		DOES ONLY LIST table.
		          FOR EACH c IN component OF THIS DO
				SAY "The table has" SAY AN c. "." LIST c.
			  END FOR.
	END VERB.

END THE.


THE cup ISA OBJECT IN table.
END THE.


THE drawer ISA OBJECT AT livingroom

	IS closeable. IS closed.
	
END THE.








A weapon
========


1)


THE pistol ISA WEAPON IN table.
	
	IS fireable.

END THE.



2)


THE sword ISA WEAPON IN hero.	
END THE.
	

(By default, weapons are NOT fireable.)





A window
========


THE bedroom_Window ISA WINDOW AT bedroom
END THE.




ACTORS
======



A basic actor
=============


THE cat ISA ACTOR AT living_room
END THE.



A person
========


THE clerk ISA PERSON AT office
END THE.


- the difference between a basic actor and a person is that persons have the ability to talk



A named person
==============


THE jim ISA PERSON

	NAME Jim

	IS named.		(by default, all actors are NOT named)

END THE.



+ changing an unnamed person to named mid-game:


THE jim ISA PERSON
	
	NAME man NAME Jim

	MENTIONED 
		IF jim IS NOT named 
			THEN "man"
			ELSE "Jim"
		END IF.


	VERB greet
		DOES 
			IF jim IS NOT named
				THEN """Hello, what's your name?"", you ask the man.
					$p""Jim,"" he answers."
					MAKE jim named.
				ELSE "You have already greeted Jim."
			END IF.
	END VERB.

END THE.




A following NPC (non-player character)
======================================



1) An NPC that follows the hero from the start of the game:


THE servant ISA PERSON AT kitchen

	IS following.

END THE.



2) Making an NPC following mid-game:



THE bob ISA PERSON AT street

	...

	VERB give
		WHEN  recip		
		DOES 
			IF obj = money
				THEN 	"""Ok, I'll come with you"", Bob says."
					MAKE bob following.
				ELSE """No deal,"", Bob snaps."
			END IF.
	END VERB.


END THE.



3) Stopping an NPC from following


THE bob ISA PERSON AT street

	...


	VERB stop
		DOES ONLY """Ok, I'll wait here"", Bob says."
			   MAKE bob NOT following.
	END VERB.


END THE.
