This is a short introduction to the standard library for Alan v3. After reading this brief introduction you will probably want to have a look at the Alan Library Cookbook.
There are four files in the standard library. You should have them in the same folder as your source code file. Then, you can include the library by using the 'import' statement in your source code.
1) The file 'verbs.i' declares some 165 verbs and commands, among others 'about', 'ask', 'answer', 'buy', 'consult', 'empty', 'fill', 'get up','look through', 'look out of', 'pour', 'push with', 'put in', 'rub', 'scratch', 'shoot', 'sit', 'sleep', 'swim', 'take from', 'tell', 'think', and 'write', to mention just a handful.
Also reactions to player input in question form such as 'who am i', 'where is (object)' etc. have been implemented.
2) The file 'classes.i' defines various object and actor classes and attributes. Examples of object classes are for example backgrounds, scenery objects, lightsources, liquids, doors, windows, clothing and devices.
For example, if you declare an object to be a liquid, you can pour it in or on something, fill something with it, etc. It is also possible to mix liquids with each other. A device object can be turned (=switched) on or off - if it is not broken, etc. Clothing can be worn in layers: the library checks that if you are wearing a jacket, you can't put on a shirt, etc.
Actor classes include e.g. female and male. Actors can be e.g. made to follow the hero just by giving them the attribute 'following' when needed.
3) The file 'locations.i' defines various location classes and attributes.
For example, to implement a simple location in ALAN, you basically do something like this:
THE park ISA LOCATION DESCRIPTION "You are taking a stroll in a pleasant green park." "The exit is to the west." EXIT west TO street. END park.
Now, as the park is an outdoor location, you would naturally need a ground object and a sky object there.
The library helps to implement outdoor and indoor locations by introducing the location classes 'room' and 'site'. 'Rooms' are indoor locations which automatically have floors, walls and ceilings, and 'sites' are outdoor locations with a ground and a sky. Thus, if you declare
THE park ISA SITE DESCRIPTION "You are taking a stroll in a pleasant green park." "The exit is to the west." EXIT west TO street. END park.
the park location will now have a ground and a sky automatically. Similarly, if you declare
THE kitchen ISA ROOM DESCRIPTION
"This is a modern kitchen with many devices and utensils." EXIT east TO bedroom. END kitchen.
you will have an indoor location with a floor, walls and a ceiling. In addition, the library takes care of the ceiling and the sky being automatically out of reach - 'reachable' is an attribute that the library uses in many verb definitions to check that objects cannot be manipulated if they are out of reach of the player character.
There is also a class for dark locations. In these, actions requiring seeing have been disabled.
Attributes for locations include e.g. 'visited' and 'described'.
4) The fourth file is called 'messages.i'. It contains all the standard predefined runtime messages in the ALAN language in one place, for easy modification. For example, if you want to change the default "You can't go that way" message, you just need to locate the appropriate message (in this case 'noway') in the list and change the message inside the quotes:
MESSAGE ... NOWAY: "There is nothing interesting in that direction."
There is also a sample game included with the library distribution, for the IF author to be able to test different responses and object behaviour.
Examples and tips of use have been included in the library files in between code, to have the code and the instructions close to each other. There is also a separate quick reference file which gives a quick overview of all the most important features.
The following posts will deal with some of the above features explained in a somewhat closer detail.
You will find the ALAN system and all its downloads, including the extensive library, at www.alanif.se.