Appendix B – “Heidi” story

../_images/picH.png

eidi in the Forest is our first – and simplest – game. We describe it in three chapters: Heidi: our first Inform game, Reviewing the basics and Heidi revisited. Here is a run-time transcript, and then the original and extended source files.

Transcript of play

Heidi
A simple Inform example
by Roger Firth and Sonja Kesserich.
Release 1 / Serial number 040804 / Inform v6.30 Library 6/11 SD

In front of a cottage
You stand outside a cottage. The forest stretches east.

>VERBOSE
Heidi is now in its "verbose" mode, which always gives long descriptions of
locations (even if you've been there before).

>GO EAST

Deep in the forest
Through the dense foliage, you glimpse a building to the west. A track heads to the
northeast.

You can see a baby bird here.

>EXAMINE THE BIRD
Too young to fly, the nestling tweets helplessly.

>TAKE BIRD
Taken.

>NE

A forest clearing
A tall sycamore stands in the middle of this clearing. The path winds southwest
through the trees.

You can see a bird's nest (which is empty) here.

>PUT BIRD IN NEST
You put the baby bird into the bird's nest.

>EXAMINE THE NEST
The nest is carefully woven of twigs and moss.

>TAKE NEST
Taken.

>UP

At the top of the tree
You cling precariously to the trunk.

You can see a wide firm bough here.

>PUT NEST ON BRANCH
You put the bird's nest on the wide firm bough.

      *** You have won ***

In that game you scored 0 out of a possible 0, in 10 turns.

Would you like to RESTART, RESTORE a saved game or QUIT?
> QUIT

Game source code – original version

!% -SD

!===============================================================================
Constant Story "Heidi";
Constant Headline
            "^A simple Inform example
             ^by Roger Firth and Sonja Kesserich.^";
Constant MAX_CARRIED 1;

Include "Parser";
Include "VerbLib";

!===============================================================================
! The game objects

Object  before_cottage "In front of a cottage"
  with  description
            "You stand outside a cottage. The forest stretches east.",
        e_to forest,
  has   light;

Object  forest "Deep in the forest"
  with  description
            "Through the dense foliage, you glimpse a building to the west.
             A track heads to the northeast.",
        w_to before_cottage,
        ne_to clearing,
  has   light;

Object  bird "baby bird" forest
  with  description "Too young to fly, the nestling tweets helplessly.",
        name 'baby' 'bird' 'nestling',
  has   ;

Object  clearing "A forest clearing"
  with  description
            "A tall sycamore stands in the middle of this clearing.
             The path winds southwest through the trees.",
        sw_to forest,
        u_to top_of_tree,
  has   light;

Object  nest "bird's nest" clearing
  with  description "The nest is carefully woven of twigs and moss.",
        name 'bird^s' 'nest' 'twigs' 'moss',
  has   container open;

Object  tree "tall sycamore tree" clearing
  with  description
            "Standing proud in the middle of the clearing,
             the stout tree looks easy to climb.",
        name 'tall' 'sycamore' 'tree' 'stout' 'proud',
  has   scenery;

Object  top_of_tree "At the top of the tree"
  with  description "You cling precariously to the trunk.",
        d_to clearing,
  has   light;

Object  branch "wide firm bough" top_of_tree
  with  description "It's flat enough to support a small object.",
        name 'wide' 'firm' 'flat' 'bough' 'branch',
        each_turn [; if (nest in branch) deadflag = 2; ],
  has   static supporter;

!===============================================================================
! Entry point routines

[ Initialise; location = before_cottage; ];

!===============================================================================
! Standard and extended grammar

Include "Grammar";

!===============================================================================

Game source code – revisited

!% -SD

!===============================================================================
Constant Story "Heidi";
Constant Headline
            "^A simple Inform example
             ^by Roger Firth and Sonja Kesserich.^";
Constant MAX_CARRIED 1;

Include "Parser";
Include "VerbLib";

!===============================================================================
! The game objects

Object  before_cottage "In front of a cottage"
  with  description
            "You stand outside a cottage. The forest stretches east.",
        e_to forest,
        in_to "It's such a lovely day -- much too nice to go inside.",
        cant_go "The only path lies to the east.",
  has   light;

Object  cottage "tiny cottage" before_cottage
  with  description "It's small and simple, but you're very happy here.",
        name 'tiny' 'cottage' 'home' 'house' 'hut' 'shed' 'hovel',
        before [;
          Enter:
            print_ret "It's such a lovely day -- much too nice to go inside.";
        ],
  has   scenery;

Object  forest "Deep in the forest"
  with  description
            "Through the dense foliage, you glimpse a building to the west.
             A track heads to the northeast.",
        w_to before_cottage,
        ne_to clearing,
  has   light;

Object  bird "baby bird" forest
  with  description "Too young to fly, the nestling tweets helplessly.",
        name 'baby' 'bird' 'nestling',
        before [;
          Listen:
            print "It sounds scared and in need of assistance.^";
            return true;
        ],
  has   ;

Object  clearing "A forest clearing"
  with  description
            "A tall sycamore stands in the middle of this clearing.
             The path winds southwest through the trees.",
        sw_to forest,
        u_to top_of_tree,
  has   light;

Object  nest "bird's nest" clearing
  with  description "The nest is carefully woven of twigs and moss.",
        name 'bird^s' 'nest' 'twigs' 'moss',
  has   container open;

Object  tree "tall sycamore tree" clearing
  with  description
            "Standing proud in the middle of the clearing,
             the stout tree looks easy to climb.",
        name 'tall' 'sycamore' 'tree' 'stout' 'proud',
        before [;
          Climb:
            PlayerTo(top_of_tree);
            return true;
        ],
  has   scenery;

Object  top_of_tree "At the top of the tree"
  with  description "You cling precariously to the trunk.",
        d_to clearing,
        after [;
          Drop:
            move noun to clearing;
            return false;
        ],
  has   light;

Object  branch "wide firm bough" top_of_tree
  with  description "It's flat enough to support a small object.",
        name 'wide' 'firm' 'flat' 'bough' 'branch',
        each_turn [; if (bird in nest && nest in branch) deadflag = 2; ],
  has   static supporter;

!===============================================================================
! Entry point routines

[ Initialise; location = before_cottage; ];

!===============================================================================
! Standard and extended grammar

Include "Grammar";

!===============================================================================