11.1. Start-Up Features

| Chapter 11: Out Of World Actions and Effects |

| 11.1. Start-Up Features

When the story file starts up, it normally prints a short introductory passage of text (the "overture") and then a heading describing itself, together with some version numbering (the "banner"). It is traditional that the banner must appear eventually (and one of the few requirements of the Inform licence is that the author acknowledge Inform somewhere, for which the banner is sufficient) but some designs call for a multi-turn prologue before the banner finally appears, and marks the start of play in earnest. Bikini Atoll demonstrates this.

If a story file represents the latest in a sequence of story files representing chapters in some larger narrative, it will need some way to pick up where its predecessor left off. This can be done with the aid of external files (in the Glulx format, at least). Alien Invasion Part 23 shows how.

Another task we might want to perform a the beginning of play is to arrange any randomized features that are supposed to change from one playing to the next. We can add such instructions with "When play begins" rule, as in:

> When play begins:
> now the priceless treasure is in a random room.

Since we may want to do something a bit more complicated than this, Hatless demonstrates effective and ineffective methods of distributing multiple objects (in this case, one randomly-selected hat per person).

See Map for a way to generate a randomized maze at the start of play

See Food for a way to choose a random piece of candy to be poisonous

See Getting Acquainted for a way to choose a murderer from among the characters at the start of each game

368
| Example Bikini Atoll Delaying the banner for later. |
WI

429
| Example Alien Invasion Part 23 Keeping a preference file that could be loaded by any game in a series. |
WI

Suppose that we have a series of games each of which allows the player to select a puzzle difficulty level. When the player plays a new game in the series, we want him to start out by default with the same difficulty level he faced earlier on, so we store this information in a small preferences file, as follows: "Alien Invasion Part 23" A difficulty is a kind of value. The difficulties are easy, moderate, hard, and fiendish. Understand "use [difficulty] puzzles" as selecting difficulty. Selecting difficulty is an action out of world, applying to one difficulty. Carry out selecting difficulty: choose row 1 in the Table of Preference Settings; now challenge level entry is difficulty understood; say "Puzzles will be [challenge level entry] from now on." The File of Preferences is called "prefs". When play begins: if File of Preferences exists: read File of Preferences into the Table of Preference Settings; choose row 1 in the Table of Preference Settings; say "(The current puzzle difficulty is set to [challenge level entry].)" Check quitting the game: write File of Preferences from the Table of Preference Settings. Table of Preference Settings challenge level easy The Sewer Junction is a room. Our preference file is restricted to a single option here for simplicity's sake, but we could keep track of more information -- whether the player preferred verbose or brief room descriptions, screen configurations, and so on. If we were disposed to be somewhat crueler, we could use a similar method to make the player finish each episode of the series in order to "unlock" the next. All we would need to do is store a numerical password in our preferences file when the player finished a given level; the next level would check, say, the Table of Completed Levels for that password, and refuse to play unless the right number were present.

126
| Example Hatless It's tempting to use "now..." to distribute items randomly at the start of play, but we need to be a little cautious about how we do that. |
WI

Previous | Contents | Next