4.7. New either/or properties

| Chapter 4: Kinds |

| 4.7. New either/or properties

Properties can't be handed out completely freely. In the previous chapter, we saw that we were allowed to make a chair "portable" and to make a room "dark". But if we try this the other way round, Inform produces a Problem message. This is because every property must be created in a way which lays out what values are allowed to have it. The Standard Rules built into Inform say that

> A thing can be fixed in place or portable.

and as a result it won't allow "The Savannah is portable" because the Savannah is a room, not a thing.

We must do the same. To go back to our example "dead end" kind:

> A dead end is either secret or ordinary.

This creates just one new property, not two. The names are taken as the two states of a single either/or property: secret means not ordinary, ordinary means not secret. Alternatively, we could just say:

> A dead end can be secret.

in which case the opposite of "secret" would be "not secret".

Now we have a property which can be given to any value of the kind "dead end". We're also free to add to the definitions of kinds which already exist, including those built into Inform: for instance,

> A room is either indoors or outdoors.

If we make the above definitions then all dead ends will be "ordinary" and all rooms "outdoors" unless the source text says otherwise. That is, in the absence of other information it's assumed that an either/or property is not true. We could reverse by writing:

> A dead end is usually secret. A room is usually indoors.

A property can be used by several kinds at once. For example, the built-in either/or property "open" is used by both doors and containers, even though door isn't a kind of container and container isn't a kind of door. In fact, although it's more usual to declare properties for whole kinds, they can actually be given to single values one at a time, if we like:

> The umbrella is carried by the player. The umbrella can be open.

And now the umbrella, which is a thing and not a door or container, can also have the property.

45
| Example Change of Basis Implementing sleeping and wakeful states. |
RB

Suppose we want to allow the player to go to sleep some of the time: "Change of Basis" A person is either awake or asleep. A person is usually awake. The important thing to note here is that it does not work to say "the player is either asleep or awake". This is because the player is not necessarily one specific person or thing during the game: the identity of the player can be changed, as we will see later. So if we want to make rules about the properties of the player, we should attach these rules to the "person" kind (or, if they really need to belong only to the player, to the "player-character" kind). A player-character is a kind of person. Linear Algebra Class is a room. "The blackboard is covered with square arrangements of numbers. These are supposed to convey something to you, but mostly you're finding them soporific." Now a few rules about changing from one state to the other: Instead of sleeping: now the player is asleep; say "You drop off." Instead of doing something other than waking up, waiting or sleeping when the player is asleep: say "Ssh! You're sleeping!" Instead of sleeping when the player is asleep: say "Zzzz." Instead of waking up when the player is asleep: now the player is awake; say "You come to suddenly, wiping drool from your lips." Instead of doing something other than looking or sleeping when the player is awake: say "You'd really rather just sleep through this." Test me with "wake up / sleep / look / z / sleep / wake up / look".

Previous | Contents | Next