Now that we have our game world mapped out, let's add stuff. The game doesn't automatically create the stuff we mention in room descriptions, like the mirror in the bathroom. It's up to us to define it ourselves.
I7 uses "kinds" to categorize stuff. We used a kind above when we said "The Stateroom is a room." That tells I7 that the object called the Stateroom is a kind of room. There can be more specific versions of any kind. For example, I7 knows about persons. It also knows that a man and a woman are more specific kinds of persons.
To see what kinds of objects I7 knows about, select the Index tab in the right side. Remember, if it's blank, press F7 to compile your game and fill in the Index's information. Under the Index tab, press the Kinds button. This page lists all the kinds that I7 knows about. They're grouped by what they're related to. At the top of the list is "object," the most fundamental kind of stuff in I7. A thing is a kind of object, so it's listed and indented under object. A person is a specific kind of thing, so it's listed and indented under object, about halfway down the list. A man is a specific kind of person, so it's listed and indented under person. Unless you say otherwise, I7 will usually assume that anything you create is a thing.
Now back to our game. The Stateroom is very bare. Let's add a promotional leaflet to the Stateroom extolling the virtues of our trip. Under the paragraph about the Stateroom, add the following paragraph.
The leaflet is in the Stateroom. The description is "It goes on and on about how wonderful the Thaleia is. Should you have trouble sleeping later, reading this could help."
"The description is" tells I7 what should be printed when you look at the leaflet. If you run the game now, you'll see a leaflet on the floor, which you can pick up and read.
While the leaflet makes the Stateroom less empty, the room doesn't even have a place for the player to sleep! Let's add a bed to the room.
The bed is in the Stateroom.
That's not bad. If you press F5 to compile and run the game, you'll see the bed in the Stateroom. However, try taking the bed. Whoops, it's portable. Even worse, try typing >ENTER BED. You can't get in it! To fix these problems, we need to give the bed some attributes, and possibly define it as a different "kind".
Use the Skein
I7 keeps track of all of the commands you've ever typed while playing your game. They're stored in the Skein tab in the right-hand pane. The Skein is a tree view of the commands, branching every time you entered a different command than you did on a previous play-through. You can name branches of the tree for easy reference, and by double-clicking on a node you will play through the game using all the commands in the branches leading to that node. As your game gets more complex, use the Skein to test your game. This gives you more flexibility than the Replay button, since you can try different commands on a runthrough but go back to your standard runthrough later.
In the Index, select the Kinds button. We'll select a better kind for the bed than "thing". If you click on the grey magnifying glass icon next to any kind, you'll see a description of that kind. We need to make the bed a supporter, so that players can put things on it if they wish. If you click on the grey magnifying glass icon next to supporter, you'll see "Normally fixed in place not portable." In other words, supporters by default can't be taken, which is what we want for the bed. Change the paragraph about the bed to be:
The bed is a supporter in the Stateroom.
Now we can take the leaflet and put it on the bed, and we can't take the bed itself. However, we can't get in the bed. Play the game and type >GET IN BED to see. To be able to enter the bed, we need to change the definition of the bed.
The bed is an enterable supporter in the Stateroom.
We could now re-run the game by pressing F5. Instead, press the green button with the circular arrows, just to the right of the Go! button. That's the replay button, and it plays through the game using the exact same commands as last time. If you typed >GET IN BED last time, the Replay button will re-try that command, only this time it should work. Replay is useful for re-testing a game when you discover a bug, make a change to the code, and then want to make sure you fixed the bug.
Let's add one more refinement to the bed. In the room description, we mentioned the furniture. Right now the only furniture is the bed. It would be nice if the game allowed players to refer to the bed as furniture. To do so, we need to use an Understand sentence. Add the following sentence to the paragraph about the bed:
Inform 7's basis in English can lead you to write code that reads okay but that I7 doesn't understand. When that happens, I7 prints a Problem Message. In stating the Problem, I7 includes orange arrow icons to take you to the offending sentences.
Understand "furniture" as the bed.
"Understand" tells I7 that we want to be able to refer to a prop by a different name. By default I7 knows that, if a player types "bed", they're refering to the bed. By adding the above Understand sentence, we're telling I7 that if a player types "furniture", I7 should refer to the bed as well.
In describing the Bathroom, we mentioned that it has a mirror. Let's add that now, below the Bathroom paragraph.
The mirror is scenery in the Bathroom. The description is "You look tired after your long shuttle flight to the Thaleia."
"Scenery" is an attribute that most kinds can have. Props that are scenery are fixed in place, and aren't described separately from the room, the way the bed in the Stateroom is.
Finally, let's add a shower to the Bathroom. Add this paragraph somewhere under the Bathroom paragraph:
The shower is here. It is fixed in place. "Opposite the mirror is the shower, which is closed." The description of the shower is "When it's open, you get in it to take a shower. Right now it's closed, keeping you from using it."
There are three new ideas introduced in this paragraph. First, notice how we said that the shower is "here"? "Here" refers to the last room we defined. If we had put the shower paragraph under the Stateroom paragraph instead of the Bathroom paragraph, it would be in the Stateroom and not the Bathroom. Second, the shower is fixed in place so light-fingered players won't tuck it in their pockets. Third, the sentence in quotes is the paragraph of text that will be printed in the Bathroom. If we hadn't specified the shower's description in the room, then I7 would print, "You see a shower here."
We described the shower as being closed so we wouldn't have to deal with the player trying to use it. But what if the player tries to open it? If you run the game and try it yourself, you'll be told, "That's not something you can open." While strictly true, that message isn't very satisfying. We can do better by using a rule.
Rules define how the game world works. You specify when a rule applies and what happens when the rule is followed. I7 uses rules to define what happens normally. We can add our own rules to change I7's behavior. In this case, instead of I7 printing the default message when players try to open the shower, we want our game to say something else. Add the following sentence to the end of the shower paragraph:
Instead of opening or entering the shower, say "It is locked down until after the ship makes its jump to hyperspace."
This is an "Instead" rule. Instead rules bypass I7's normal rules and replace them with our own. In this case, we're telling I7 not to do what it normally does if the player tries to open or enter the shower. Instead, our game should explain that the shower is locked for now.
We can do something similar with a door in the Stateroom. The Stateroom's description says that the door to the hallway is locked tight. Let's add a door to the Stateroom that tells players that it's locked if the players try to open it.
The hallway door is scenery in the Stateroom. Instead of opening or entering the hallway door, say "The captain has locked all stateroom doors in preparation for jumping to hyperspace."
There are more types of rules than just Instead rules. As a demonstration of rules' other powers, let's fix an ongoing problem with our game. When you start The Grand Tour, you're dumped into the Stateroom with no explanation, and only a leaflet to give you some idea of what's going on. Let's start the game with the captain announcing the lockdown over the intercom. We can do that by writing a new rule that will be followed at the start of the game. Near the top of the source, add this rule:
When play begins: say "The intercom crackles to life. 'This is your captain speaking. We're jumping to hyperspace shortly, so for your protection, we've locked all stateroom doors. As soon as we've safely jumped, your doors will open and you will be free to move about the ship.'"
I7 will automatically turn the single quotes into double quotes. Try playing the game now, and you should see the above paragraph before the game's name is printed.