§5.2. Traits Determined By the Player

Some IF tries to make the viewpoint character more congenial to the player by allowing some customization.

Identity Theft demonstrates asking the player to supply the viewpoint character's name.

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.

This is not the only way to go - as we'll see in the next section, there's also something to be said for making the viewpoint character a strongly distinct creature with well-defined preferences and attitudes.


arrow-up.pngStart of Chapter 5: The Viewpoint Character
arrow-left.pngBack to §5.1. The Human Body
arrow-right.pngOnward to §5.3. Characterization

*ExampleIdentity Theft
Allowing the player to enter a name to be used for the player character during the game.

The "reading a command" activity is rather advanced; for the moment, what we need to understand is that we're intervening in commands at the start of play and insisting that the player's first instruction to the game consist of a choice of gender. After that point, the gender will be set and play will proceed as normal.

In order to do the parsing, we define gender as a kind of value, and give several alternate names to each gender.

paste.png "Baritone, Bass"

Getting Started is a room.

Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand "male" or "man" or "M" as masculine. Understand "female" or "woman" or "F" as feminine.

A person has a gender. The gender of the player is unknown.

When play begins:
    now the command prompt is "Please choose a gender for your character. >".

After reading a command when the gender of the player is unknown:
    if the player's command includes "[gender]":
        now the gender of the player is the gender understood;
        if the gender of the player is unknown:
            say "This story requires a selection of male or female. [run paragraph on]";
            reject the player's command;
        if the gender of the player is masculine, now the player is male;
        if the gender of the player is feminine, now the player is female;
        say "[line break]Thank you. We now begin...";
        now the command prompt is ">";
        move the player to Sandy Beach;
        reject the player's command;
    otherwise:
        say "Sorry, we're not ready to go on yet. [run paragraph on]";
        reject the player's command.

Sandy Beach is a room.

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!"

If we had a whole series of things to ask the player about, we might define a whole series of kinds of value

The vocal ranges are soprano, mezzosoprano, contralto...

and use a "construction stage" variable to keep track of the current stage of character-construction, as in

After reading a command when the current construction stage is choosing a vocal range:
    ...

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

The "reading a command" activity is rather advanced; for the moment, what we need to understand is that we're intervening in commands at the start of play and insisting that the player's first instruction to the game consist of a choice of gender. After that point, the gender will be set and play will proceed as normal.

In order to do the parsing, we define gender as a kind of value, and give several alternate names to each gender.

paste.png "Baritone, Bass"

Getting Started is a room.

Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand "male" or "man" or "M" as masculine. Understand "female" or "woman" or "F" as feminine.

A person has a gender. The gender of the player is unknown.

When play begins:
    now the command prompt is "Please choose a gender for your character. >".

After reading a command when the gender of the player is unknown:
    if the player's command includes "[gender]":
        now the gender of the player is the gender understood;
        if the gender of the player is unknown:
            say "This story requires a selection of male or female. [run paragraph on]";
            reject the player's command;
        if the gender of the player is masculine, now the player is male;
        if the gender of the player is feminine, now the player is female;
        say "[line break]Thank you. We now begin...";
        now the command prompt is ">";
        move the player to Sandy Beach;
        reject the player's command;
    otherwise:
        say "Sorry, we're not ready to go on yet. [run paragraph on]";
        reject the player's command.

Sandy Beach is a room.

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!"

If we had a whole series of things to ask the player about, we might define a whole series of kinds of value

The vocal ranges are soprano, mezzosoprano, contralto...

and use a "construction stage" variable to keep track of the current stage of character-construction, as in

After reading a command when the current construction stage is choosing a vocal range:
    ...

***ExamplePink or Blue
Asking the player to select a gender to begin play.