X-Git-Url: https://jxself.org/git/?p=ibg.git;a=blobdiff_plain;f=chapters%2F04.rst;h=b01d7732d021218faeb9ddf0eb2f9d8f5193539b;hp=51454ab03789013076bbef43215268f9245c1796;hb=8009937904cf79341a9c23c9c5e7b541606bfcb6;hpb=fb8b7c14f10733e913e2b87f9a82e5b44c0dc7be diff --git a/chapters/04.rst b/chapters/04.rst index 51454ab..b01d773 100644 --- a/chapters/04.rst +++ b/chapters/04.rst @@ -4,6 +4,8 @@ .. highlight:: inform +.. default-role:: samp + .. epigraph:: | |CENTER| *G was a gamester, who had but ill-luck;* @@ -68,6 +70,10 @@ but you can change it at any time. For example, we used the statement:: location = before_cottage; +.. Generated by autoindex +.. index:: + pair: location; library variable + to reset the value of the :var:`location` variable to the ``before_cottage`` object, and we wrote:: @@ -89,20 +95,16 @@ room is an object, each item that the player sees and touches is an object; indeed the player herself is also an object (one that's automatically defined by the library). -.. todo:: - - The set-off below needs to be tweaked or perhaps a custom lexer - created to get italics in the right places. +The general model of an :term:`object` definition looks like this: -The general model of an :term:`object` definition looks like this:: - - Object obj_id "external_name" parent_obj_id - with property value , - property value , - ... - property value , - has attribute attribute ... attribute - ; + | `Object {obj_id} "{external_name}" {parent_obj_id}` + | `with` + | `{property} {value},` + | `{property} {value},` + | `...` + | `{property} {value},` + | `has {attribute} {attribute} ... {attribute}` + | `;` The definition starts with the word ``Object`` and ends with a semicolon; in between are three major blocks of information: @@ -116,22 +118,22 @@ Object headers An object header comprises up to three items, all optional: -* An internal ``obj_id`` by which other objects refer to this object. It's +* An internal `{obj_id}` by which other objects refer to this object. It's a single word (though it can contain digits and underscores) of up to thirty-two characters, and it must be unique within the game. You can - omit the ``obj_id`` if this object isn't referred to by any other + omit the `{obj_id}` if this object isn't referred to by any other objects. For example: ``bird``, ``tree``, ``top_of_tree``. -* An ``external_name``, in double quotes, which is what the interpreter +* An `{external_name}`, in double quotes, which is what the interpreter uses when referring to the object. It can be one or more words, and need not be unique (for instance, you might have several ``"Somewhere in the desert"`` rooms). Although not mandatory, it's best to give *every* - object an ``external_name``. For example: ``"baby bird"``, ``"tall + object an `{external_name}`. For example: ``"baby bird"``, ``"tall sycamore tree"``, ``"At the top of the tree"``. -* The internal ``obj_id`` of another object which is the initial location +* The internal `{obj_id}` of another object which is the initial location of this object (its "parent" -- see the next section) at the start of the game. This is omitted from objects which have no initial parent; it's *always* omitted from a room. @@ -435,6 +437,10 @@ into individual words, which it then looks up in the dictionary. If it finds all the words, and they seem to represent a sensible course of action, that's what happens next. +.. Generated by autoindex +.. index:: + pair: name; library property + So far, we've seen dictionary words used as the values of an object :prop:`name` property:: @@ -487,6 +493,10 @@ interpreter executes that statement: it performs an assignment:: deadflag = 2; +.. Generated by autoindex +.. index:: + pair: deadflag; library variable + which changes the value of the library variable :var:`deadflag` from its current value to 2. Incidentally, ``if`` statements are often written on two lines, with the "controlled" statement indented. This makes it