============================
The town square, notionally one enormous open space, is represented by
-three rooms. Here's the south side::
+three rooms. Here's the south side:
+
+.. include:: /config/typethis.rst
+
+::
Room south_square "South side of the square"
with description
:prop:`found_in` both this room and the north side of the square, even if it's
"too far away" for a detailed description.
+.. Generated by autoindex
+.. index::
+ pair: Examine; library action
+ pair: before; library property
+
In fact, it's "too far away" for anything. We've replaced the standard
-:prop:`before` action for the ``Prop`` class (which permits ``Examine``, but
-rejects other actions with "You don't need to worry about...") with one
+:prop:`before` action for the ``Prop`` class (which permits :act:`Examine`,
+but rejects other actions with "You don't need to worry about...") with one
rejecting *all* actions. Since Wilhelm's hatred of the vogt's activities
is central to our plot, a message saying "You don't need to worry about the
hat" would be unacceptably misleading.
+.. Generated by autoindex
+.. index::
+ pair: FireAt; library action
+ pair: Talk; library action
+
The obnoxious soldiers are also implemented very sketchily; they need to be
there, but they don't do much. Their most interesting characteristic is
-probably that they trap two actions -- ``FireAt`` and ``Talk`` -- which are
-*not* part of the library, but instead new actions that we've defined
-specially for this game. We'll talk about those actions in :ref:`verbs`,
-at which time the role of this :prop:`before` property will make more sense.
+probably that they trap two actions -- :act:`FireAt` and :act:`Talk` --
+which are *not* part of the library, but instead new actions that we've
+defined specially for this game. We'll talk about those actions in
+:ref:`verbs`, at which time the role of this :prop:`before` property will
+make more sense.
The middle of the square
========================
attempt, patience runs out, and Wilhelm is hauled off to perform his
party piece.
-So, there are two actions that we need to look out for: ``Salute`` (trapped
-by the pole), and ``Go`` (which can be trapped by the room itself). ``Go``
-is a standard library action. ``Salute`` is one that we've devised; let's
-deal with it first. Here's a first cut of the room::
+.. Generated by autoindex
+.. index::
+ pair: Go; library action
+ pair: Salute; library action
+
+So, there are two actions that we need to look out for: :act:`Salute`
+(trapped by the pole), and :act:`Go` (which can be trapped by the room
+itself). :act:`Go` is a standard library action. :act:`Salute` is one
+that we've devised; let's deal with it first. Here's a first cut of the
+room::
Room mid_square "Middle of the square"
with description
n_to north_square,
s_to south_square;
-and the pole::
+and the pole:
+
+.. include:: /config/typethis.rst
+
+::
Furniture pole "hat on a pole" mid_square
with name 'wooden' 'pole' 'pine' 'hat' 'black' 'red' 'brim' 'feathers',
remarkable coincidence: the library provides a property with a name that's
exactly right for our game; surely not?
+.. Generated by autoindex
+.. index::
+ pair: has_been_saluted; library property
+
No, of course not. :prop:`has_been_saluted` isn't a standard library
property; it's one that we've just invented. Notice how easily we did it
-- we simply included the line::
:ref:`reading-other-code`.
Back to the ``mid_square`` room. We've said that we need to detect Wilhelm
-trying to leave this room, which we can do by trapping the ``Go`` action in
-a :prop:`before` property. Let's sketch the coding we'll need::
+trying to leave this room, which we can do by trapping the :act:`Go` action
+in a :prop:`before` property. Let's sketch the coding we'll need::
before [;
Go:
if (noun == n_obj) { Wilhelm is trying to move north }
];
-We can easily trap the ``Go`` action, but which direction is he moving?
+.. Generated by autoindex
+.. index::
+ pair: Go; library action
+ pair: s_to; library property
+
+We can easily trap the :act:`Go` action, but which direction is he moving?
Well, it turns out that the interpreter turns a command of GO SOUTH (or
-just SOUTH) into an action of ``Go`` applied to an object ``s_obj``. This
-object is defined by the library; so why isn't it called just "``south``"?
-Well, because we already have another kind of south, the property :prop:`s_to`
-used to say what lies in a southerly direction when defining a room. To
-avoid confusing them, :prop:`s_to` means "south to" and ``s_obj`` means "south
-when the player types it as the object of a verb".
+just SOUTH) into an action of :act:`Go` applied to an object ``s_obj``.
+This object is defined by the library; so why isn't it called just
+"``south``"? Well, because we already have another kind of south, the
+property :prop:`s_to` used to say what lies in a southerly direction when
+defining a room. To avoid confusing them, :prop:`s_to` means "south to"
+and ``s_obj`` means "south when the player types it as the object of a
+verb".
+
+.. Generated by autoindex
+.. index::
+ pair: noun; library variable
The identity of the object which is the target of the current action is
stored in the :var:`noun` variable, so we can write the statement ``if (noun
memory, he'll completely forget Wilhelm if our hero should move away from
the pole.
+.. Generated by autoindex
+.. index::
+ pair: has_been_saluted; library property
+ pair: warnings_count; library property
+
To do all this, we've added a new property and two statements. The
property is :prop:`warnings_count`, and its value will count how many times
Wilhelm has tried to go north without saluting the pole: 0 initially, 1
return true;
}
+.. Generated by autoindex
+.. index::
+ pair: Go; library action
+
The first part is really just displaying a lot of text, made slightly
messier because we're adding emphasis to the word "Herr" by using
underlining (which actually comes out as *italic type* on most
interpreters). Then, we make sure that Walter has the apple (just in case
we didn't give it to him earlier in the game), relocate to the final room
using ``PlayerTo(marketplace)``, and finally ``return true`` to tell the
-interpreter that we've handled this part of the ``Go`` action ourselves.
+interpreter that we've handled this part of the :act:`Go` action ourselves.
And so, at long last, here's the complete code for the ``mid_square``, the
-most complicated object in the whole game::
+most complicated object in the whole game:
+
+.. include:: /config/typethis.rst
+
+::
Room mid_square "Middle of the square"
with description
============================
The only way to get here is by saluting the pole and then moving north; not
-very likely, but good game design is about predicting the unpredictable. ::
+very likely, but good game design is about predicting the unpredictable.
+
+.. include:: /config/typethis.rst
+
+::
Room north_square "North side of the square"
with description
In this game, we never set :var:`deadflag` to 1, but we do use values of 2
and 3. So we'd better define a ``DeathMessage`` routine to tell players
-what they've done::
+what they've done:
+
+.. include:: /config/typethis.rst
+
+::
[ DeathMessage; print "You have screwed up a favourite folk story"; ];