Chapter 5: The Viewpoint Character
5.1. The Human Body

By default, Inform gives the player character (and every other person) a simple unitary body, one without hands or feet or any other defined parts. In many games this is adequate; but in others it is not enough, and we may want to endow all people with some more specific physical features, as in

A face is a kind of thing. A face is part of every person.

Once we've done this, we may invite ambiguities if the player types LOOK AT FACE; it is this challenge that is addressed in The Night Before.

Our other examples have more specialized effects. Pink or Blue demonstrates a way to let the player choose a gender at the start of play: this will mostly be interesting if the rest of the game makes some use of the player's choice. Since that example is written expressly to demonstrate included Inform 6 code, however, we may find it more congenial to generalize from the more flexible Baritone, Bass.

rBGH gives him a random height and then uses this to determine how the room should be described around him.


44
*** Example  The Night Before
Instructing Inform to prefer different interpretations of EXAMINE NOSE, depending on whether the player is alone, in company, or with Rudolph the Red-nosed Reindeer.

WI
353
*** Example  Pink or Blue
Asking the player to select a gender to begin play.

WI

Suppose we would like to allow the player to choose a gender for the main character. We'd also like this to happen at the beginning of the game and outside the main parsing sequence. "When play begins" seems like a good place to put this.

"Pink or Blue"

When play begins:
    say "Should your character be male or female? >";
    if men win, now the player is male;
    otherwise now the player is female;
    say paragraph break.

Now a piece of Inform 6 code handles the unusual input. It's not necessary to understand this to use it, and the code should work for any question you'd like to ask the player. The first three words in quotation marks ('male', 'M', 'man'...) correspond to positive feedback; the later three words correspond to negative feedback. So "to decide whether men win" will be true if the player types one of the first three, and false if he types one of the last three.

To decide whether men win:
    (- Question('male','M//','man','female','F//','woman') -)

Include (-

[ Question pos1 pos2 pos3 neg1 neg2 neg3 i;
    for (::)
    { if (location == nothing || parent(player) == nothing) read buffer parse;
        else read buffer parse DrawStatusLine;
        i=parse-->1;
        if (i==pos1 or pos2 or pos3) rtrue;
        if (i==neg1 or neg2 or neg3) rfalse;
        print "Please choose ", (address) pos1, " or ", (address) neg1, ". > ";
    }
];

-)

Instead of examining the player when the player is female:
    say "Congratulations, you are a girl!"

Instead of examining the player when the player is male:
    say "Congratulations, you are a boy!"

The Room of Self-Knowledge is a room. "Mirrors cover every available wall-surface of this hexagonal chamber, allowing you to examine yourself from all angles."

262
*** Example  Baritone, Bass
Letting the player pick a gender (or perhaps other characteristics) before starting play.

WI
216
* Example  rBGH
The player character's height is selected randomly at the start of play.

WI


PreviousContentsNext