Address more of the TODO items.
[ibg.git] / chapters / 07.rst
index c7a8ad0494f61745af2ea25de1598e2087a541b3..fad0f1c94a506675c93d278a29764073fd09d96c 100644 (file)
@@ -22,7 +22,11 @@ stallholder.
 Defining the street
 ===================
 
-This is the street room, the location where the game starts::
+This is the street room, the location where the game starts:
+
+.. include:: /config/typethis.rst
+
+::
 
    Room     street "A street in Altdorf"
      with   description [;
@@ -85,6 +89,10 @@ The line of dialogue is produced by the ``print`` statement, the ``print``
 statement is controlled by the ``if`` statement, and the ``if`` statement
 is performing the test ``self hasnt visited``.  In detail:
 
+.. Generated by autoindex
+.. index::
+   pair: visited; library attribute
+
 * :attr:`visited` is an attribute, but not one that you'd normally give to an
   object yourself.  It's automatically applied to a room object by the
   interpreter, but only after that room has been visited for the first
@@ -97,6 +105,10 @@ is performing the test ``self hasnt visited``.  In detail:
   if object :samp:`{X}` currently does not have attribute :samp:`{Y}`,
   false if it does.
 
+.. Generated by autoindex
+.. index::
+   pair: self; library variable
+
 * :var:`self`, which we met in the previous chapter, is that useful variable
   which, within an object, always refers to that object.  Since we're using
   it in the middle of the ``street`` object, that's what it refers to.
@@ -145,7 +157,11 @@ Adding some props
 The street's description mentions various items -- the gate, the people,
 etc. -- which ought to exist within the game (albeit only in minimal form)
 to sustain the illusion of hustle and bustle.  Our ``Prop`` class is ideal
-for this::
+for this:
+
+.. include:: /config/typethis.rst
+
+::
 
    Prop     "south gate" street
      with   name 'south' 'southern' 'wooden' 'gate',
@@ -185,6 +201,10 @@ for this::
    :samp:`{external_names}`, because these are used by the ``Prop`` class's
    ``print_ret ... (the) self`` statement.
 
+.. Generated by autoindex
+.. index::
+   pair: pluralname; library attribute
+
 You'll see a couple of new attributes: :attr:`animate` marks an object as
 being "alive", while :attr:`pluralname` specifies that its external name is
 plural rather than singular.  The interpreter uses these attributes to
@@ -195,6 +215,10 @@ it's hard to be sure exactly what messages players may trigger; the best
 approach is to play safe and always give an object the relevant set of
 attributes, even when, as here, they probably won't be needed.
 
+.. Generated by autoindex
+.. index::
+   pair: found_in; library property
+
 You'll also see a new :prop:`found_in` property, which specifies the rooms
 -- and only the rooms; :prop:`found_in` shouldn't be used to place objects
 inside containers or supporters -- where this object is to appear.  The
@@ -264,7 +288,11 @@ The player's possessions
 ========================
 
 Since our ``Initialise`` routine has already mentioned them, we might as
-well define Wilhelm's bow and arrows::
+well define Wilhelm's bow and arrows:
+
+.. include:: /config/typethis.rst
+
+::
 
    Object   bow "bow"
      with   name 'bow',
@@ -285,16 +313,20 @@ well define Wilhelm's bow and arrows::
             ],
      has    container open clothing;
 
-Both of these are straightforward objects, with the ``Drop``, ``Give`` and
-``ThrowAt`` actions being intercepted to ensure that Wilhelm is never
-without them.  The :attr:`clothing` attribute makes its first appearance,
-marking both the quiver and the bow as capable of being worn (as the result
-of a WEAR BOW command, for instance); you'll remember that our
-``Initialise`` routine goes on to add a :attr:`worn` attribute to the
-quiver.
+Both of these are straightforward objects, with the :act:`Drop`,
+:act:`Give` and :act:`ThrowAt` actions being intercepted to ensure that
+Wilhelm is never without them.  The :attr:`clothing` attribute makes its
+first appearance, marking both the quiver and the bow as capable of being
+worn (as the result of a WEAR BOW command, for instance); you'll remember
+that our ``Initialise`` routine goes on to add a :attr:`worn` attribute to
+the quiver.
 
 An empty quiver is pretty useless, so here's the class used to define
-Wilhelm's stock of arrows.  This class has some unusual features::
+Wilhelm's stock of arrows.  This class has some unusual features:
+
+.. include:: /config/typethis.rst
+
+::
 
    Class    Arrow
      with   name 'arrow' 'arrows//p',
@@ -339,7 +371,11 @@ listing them individually in this clumsy fashion:
 The interpreter will do this for us if our objects are "indistinguishable",
 best achieved by making them members of a class which includes both
 :prop:`name` and :prop:`plural` properties.  We define the actual arrows
-very simply, like this::
+very simply, like this:
+
+.. include:: /config/typethis.rst
+
+::
 
    Arrow "arrow" quiver;
    Arrow "arrow" quiver;
@@ -384,7 +420,11 @@ of cakes".
 Moving further along the street
 ===============================
 
-As Wilhelm moves north towards the square, he comes to this room::
+As Wilhelm moves north towards the square, he comes to this room:
+
+.. include:: /config/typethis.rst
+
+::
 
    Room     below_square "Further along the street"
      with   description
@@ -394,7 +434,11 @@ As Wilhelm moves north towards the square, he comes to this room::
             n_to south_square,
             s_to street;
 
-No surprises there, nor in most of the supporting scenery objects. ::
+No surprises there, nor in most of the supporting scenery objects.
+
+.. include:: /config/typethis.rst
+
+::
 
    Furniture   stall "fruit and vegetable stall" below_square
      with name 'fruit' 'veg' 'vegetable' 'stall' 'table',
@@ -415,29 +459,42 @@ No surprises there, nor in most of the supporting scenery objects. ::
             description "Fine locally grown produce.",
      has    pluralname;
 
+.. Generated by autoindex
+.. index::
+   pair: before; library property
+
 The only new thing here is the :prop:`before` property of the fruit'n'veg
 stall.  The stall's description -- lots of items on a table -- may suggest
 to players that they can SEARCH through the produce, maybe finding a lucky
 beetroot or something else interesting.  No such luck -- and we might as
 well trap the attempt.
 
-Having intercepted a ``Search`` action, our plan is to respond with the
+.. Generated by autoindex
+.. index::
+   pair: Examine; library action
+   pair: Search; library action
+
+Having intercepted a :act:`Search` action, our plan is to respond with the
 stall's description, as though the player has typed EXAMINE THE STALL.
 There isn't an easy way for us to stealthily slide those literal words into
 the interpreter, but we *can* simulate the effect which they'd cause: an
-action of ``Examine`` applied to the object stall.  This rather cryptic
+action of :act:`Examine` applied to the object stall.  This rather cryptic
 statement does the job::
 
    <Examine stall>;
 
-Having diverted the ``Search`` action into an ``Examine`` action, we must
-tell the interpreter that it doesn't need to do anything else, because
+Having diverted the :act:`Search` action into an :act:`Examine` action, we
+must tell the interpreter that it doesn't need to do anything else, because
 we've handled the action ourselves.  We've done that before -- using
 ``return true`` -- and so a first stab at the :prop:`before` action looks
 like this::
 
    before [; Search: <Examine stall>; return true; ],
 
+.. Generated by autoindex
+.. index::
+   pair: self; library variable
+
 The two-statement sequence ``<...>; return true`` is so common that there's
 a single statement shortcut: ``<<...>>``.  Also, for exactly the same
 reason as before, our code is clearer if we use :var:`self` instead of
@@ -446,7 +503,7 @@ reason as before, our code is clearer if we use :var:`self` instead of
    before [; Search: <<Examine self>>; ],
 
 A couple of final observations before we leave this topic.  The example
-here is of an action (``Examine``) applied to an object (:var:`self`,
+here is of an action (:act:`Examine`) applied to an object (:var:`self`,
 though ``stall`` or :var:`noun` would also work at this point).  You can
 also use the ``<...>`` and ``<<...>>`` statements for actions which affect
 no objects::
@@ -461,6 +518,10 @@ command PUT THE BIRD IN THE NEST can be simulated with this statement::
 Introducing Helga
 =================
 
+.. Generated by autoindex
+.. index::
+   single: NPC
+
 One of the trickiest aspects of designing a good game is to provide
 satisfying interaction with other characters.  It's hard enough to code
 inanimate objects which provoke appropriate responses to whatever actions
@@ -473,7 +534,11 @@ can be a real nightmare.
 
 But not here: we've kept our three NPCs -- Helga, Walter and the vogt -- as
 simple as possible.  Nevertheless, we can establish some fundamental
-principles; here's the class upon which we base our NPCs::
+principles; here's the class upon which we base our NPCs:
+
+.. include:: /config/typethis.rst
+
+::
 
    Class    NPC
      with   life [;
@@ -487,17 +552,34 @@ what defines an object as an NPC, and causes the interpreter to treat it a
 little differently -- for example, TAKE HELGA results in "I don't suppose
 Helga would care for that".
 
+.. Generated by autoindex
+.. index::
+   pair: Ask; library action
+   pair: Attack; library action
+   pair: Kiss; library action
+   pair: Order; library action
+   pair: Show; library action
+   pair: Tell; library action
+   pair: ThrowAt; library action
+   pair: WakeOther; library action
+   pair: life; library property
+
 The :attr:`animate` attribute also brings into play nine extra actions
-which can be applied only to animate objects: ``Answer``, ``Ask``,
-``Order`` and ``Tell`` are all associated with speech, and ``Attack``,
-``Kiss``, ``Show``, ``ThrowAt`` and ``WakeOther`` are associated with
-non-verbal interaction.  Additionally, a new :prop:`life` property -- very
-similar to :prop:`before` -- can be defined to intercept them.  Here we use
-it to trap speech-related commands such as ASK HELGA ABOUT APPLE and TELL
-WALTER ABOUT BABIES, telling players that in this game we've implemented
-only a simpler TALK verb (which we describe in :ref:`verbs`).
+which can be applied only to animate objects: :act:`Answer`, :act:`Ask`,
+:act:`Order` and :act:`Tell` are all associated with speech, and
+:act:`Attack`, :act:`Kiss`, :act:`Show`, :act:`ThrowAt` and
+:act:`WakeOther` are associated with non-verbal interaction.  Additionally,
+a new :prop:`life` property -- very similar to :prop:`before` -- can be
+defined to intercept them.  Here we use it to trap speech-related commands
+such as ASK HELGA ABOUT APPLE and TELL WALTER ABOUT BABIES, telling players
+that in this game we've implemented only a simpler TALK verb (which we
+describe in :ref:`verbs`).
 
-Based on the NPC class we've created, here's Helga::
+Based on the NPC class we've created, here's Helga:
+
+.. include:: /config/typethis.rst
+
+::
 
    NPC      stallholder "Helga" below_square
      with   name 'stallholder' 'greengrocer' 'monger' 'shopkeeper' 'merchant'
@@ -540,6 +622,11 @@ incremented.  This variable holds the number of points that the player has
 scored; when it changes like this, the interpreter tells the player that
 "Your score has just gone up by one point".
 
+.. Generated by autoindex
+.. index::
+   pair: initial; library property
+   pair: times_spoken_to; library property
+
 There are also :prop:`life` and :prop:`times_spoken_to` properties (which
 we'll talk about in :doc:`09`) and an :prop:`initial` property.