I EXAMPLE ADVENTURE
This section contains a small example of how an adventure can be written in Alan. The emphasis have not been on the ultimate features of the language. Instead it is intended to show how much functionality can be achieved by just a few hundred lines of code.
-- This is an example of an adventure written in ALAN using almost
-- nothing of the more advanced features.
-- The story is not much: You have lost your memory and stumble around
-- on a narrow path in the middle of the jungle. To the north the path
-- takes you to a river and to the south to a clearing where a tiger
-- blocks your way. The only way to get past the tiger is to eat a
-- certain kind of fungus, which works as tiger repellant (a clue about
-- this can be found in your notebook). The fungus can only be found
-- by climbing the vine hanging down over the path. When you have
-- succeded in getting past the tiger the game gets to a happy ending.
-------------
LOCATION Path
-------------
DESCRIPTION
"You are standing on a barely visible path in the middle of nowhere.
The path looks like it's been walked by bare feet (or rather paws) for
many a year. From the small amount of light reaching the ground here
I should say the path runs in almost straight north/south direction.
On both sides of the path is the deepest, darkest jungle you've ever
seen. I really wouldn't recommend going that way. The path itself
isn't much of a place to hold on to either. You get the impression
that the vegetation is trying hard to recapture even this tiny part
of land. The trees on both sides seems to come closer and there are
vines hanging down almost touching your head."
EXIT north TO bank.
EXIT south TO clearing.
EXIT east, west TO jungle.
END LOCATION.
-------------
LOCATION Bank
-------------
DESCRIPTION
"The path ends here on the south side of a wide river. On the ground
you can see lots of paw prints (some pretty big ones, too). The obvious
guess is naturally that this is a common place for the wild animals to
stop by for a drink or two (and maybe a bite too). The river itself
doesn't seem to be too dangerous - it's neither too wide nor too rapid -
but those logs with a pair of eyes give you second thoughts."
EXIT north, swim TO river.
EXIT south TO path.
EXIT east, west TO jungle.
END LOCATION.
--------------
LOCATION Trees
--------------
DESCRIPTION
"You have now ended up high above the ground in the middle of the
trees and vines. The vegetation is so thick up here that it seems
almost like a green floor."
EXIT down TO path.
END LOCATION.
--------------
LOCATION River
--------------
DESCRIPTION
"Defying the obvious horrors of the river you try for the northern
river bank. One crocodile immediately chops your left foot of, but
you makes it almost to the middle of the river before another merciful
crocodile finishes you off."
QUIT.
END LOCATION.
-----------------
LOCATION Clearing
-----------------
DESCRIPTION
"Here the jungle opens up a bit and the path takes you straight into
a clearing. The path seems to continue on the south side of the
clearing some fifty paces away."
EXIT north TO path.
EXIT east, west TO jungle.
EXIT south TO camp
CHECK hero IS repelling
ELSE "The tiger opens its big mouth and lets out a terrifying
growl. Apparently it won't let you pass."
DOES
"When you approaches the tiger it looks confused. Then it
really takes in your smell. It suddenly bolts, turns and
takes off into the jungle."
LOCATE tiger AT nowhere.
END EXIT.
END LOCATION.
---------------
LOCATION Jungle
---------------
DESCRIPTION
"Now you've really done it. Didn't I tell you NOT to enter the jungle."
EXIT north, south, east, west TO jungle DOES
"Stumbling around in the jungle trying to make your way through
the damp vegetation that almost seems to reach out for you,
you suddenly stumble onto a snake, which disapprove very clearly
of you stepping on it. One bite in the leg and you have had it."
QUIT.
END EXIT.
END LOCATION.
-------------
LOCATION Camp
-------------
DESCRIPTION
"Here is the scattered parts of what ones was the camp of your
expedition. The sight of it makes your memory come back. When
you were attacked last night of a herd of wild elephants everyone
fled in panic. You yourself ran straight into a tree and must
have lost both conciousness and memory. 'Well, hope the computer
still works.' you think. 'I think I stick to computer adventures,
at least for the immediate future.'"
QUIT.
END LOCATION.
----------------
LOCATION nowhere
----------------
-- The location for disappearing objects.
END LOCATION.
-------------------------------------------------------------------------
OBJECT Tiger AT Clearing
DESCRIPTION
"An enormous tiger is standing here blocking your way."
END OBJECT.
OBJECT Notebook IN inventory
DESCRIPTION
"The book is called 'The Jungle Book: Tricks and Tips'. It
also has your name on it."
VERB Take DOES
LOCATE OBJECT IN inventory.
"Taken!"
END VERB.
VERB Drop DOES
LOCATE OBJECT HERE.
"Dropped!"
END VERB.
VERB Read DOES
"You open the book and glance over the notes. It is really
a very strange mixture. Something about a tree you shouldn't
hide under when it rains, 'cause some kind of bugs will start
falling of its leaves, something else about a certain kind of
fungus, which grows up among the vines and when eaten is a
strong tiger repellant and something about how to make a fire
from wet moss. Here are page after page of useful hints of
how to survive in the jungle, all in your own hand writing."
END VERB.
END OBJECT.
OBJECT Vine AT Path
DESCRIPTION
"A particulary long and thick vine is hanging down just beside
you."
VERB climb DOES
"The vine is quite slippery, but you still manage to climb
well into the trees."
LOCATE HERO AT Trees.
END VERB.
END OBJECT.
OBJECT Fungus AT Trees
DESCRIPTION
"Some kind of vaguely familiar fungus is growing here on a vine."
VERB Take DOES
LOCATE OBJECT IN inventory.
"Taken!"
END VERB.
VERB Drop DOES
LOCATE OBJECT HERE.
"The fungus immediately clings to a new vine."
END VERB.
VERB eat DOES
"You try a bit of the fungus. It doesn't taste bad although it
isn't that delicious either. You swallow the rest of it almost
without chewing. After a short while a strange odour starts
perspiring from your body."
LOCATE fungus AT nowhere.
MAKE hero repelling.
END VERB.
END OBJECT.
-------------------------------------------------------------------------
SYNTAX take_inventory = 'inventory'.
SYNONYMS i = 'inventory'.
VERB take_inventory DOES
LIST inventory.
END VERB.
SYNTAX 'look' = 'look'.
SYNONYMS l = 'look'.
VERB 'look' DOES
LOOK.
END VERB.
SYNTAX 'quit' = 'quit'.
SYNONYMS q = 'quit'.
VERB 'quit' DOES
QUIT.
END VERB.
-------------------------------------------------------------------------
-- NOTE ! It is NOT necessary to declare the actor Hero (which is the
-- player himself). But IF you want to make in possible to give
-- the Hero certain attributes, THEN you have to declare it.
ACTOR Hero
IS NOT repelling.
END ACTOR.
-------------------------------------------------------------------------
START AT path.
"$p'Oh, my head. It hurts. Why am I out here when I've got this kind
of headache? And where is 'here'? And who am I?'"