§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 story 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.
![]() | Start of Chapter 5: The Viewpoint Character |
![]() | Back to §5.1. The Human Body |
![]() | Onward to §5.3. Characterization |
Let's say we want to allow the player to enter any name he likes for his character. Moreover, we want to reject very long names (which are likely to be mistakes anyway), and we want to extract the player's chosen first name from the rest.
We also want to postpone the proper beginning of the game until we've gotten the name:
If we are compiling for Glulx, this is enough to capture not only the player's name but also the capitalization he uses. If we are compiling for the Z-machine, the player's input will unfortunately be reduced to lower case before we can inspect it. If we would like by default to capitalize the first letter of each word of the name, we might substitute the following after reading a command rule:
|
|
Let's say we want to allow the player to enter any name he likes for his character. Moreover, we want to reject very long names (which are likely to be mistakes anyway), and we want to extract the player's chosen first name from the rest.
We also want to postpone the proper beginning of the game until we've gotten the name:
If we are compiling for Glulx, this is enough to capture not only the player's name but also the capitalization he uses. If we are compiling for the Z-machine, the player's input will unfortunately be reduced to lower case before we can inspect it. If we would like by default to capitalize the first letter of each word of the name, we might substitute the following after reading a command rule:
|
|
|