Inform 7 Home Page / Documentation
§4.8. New value properties
So much for either/or properties. Now we move on to properties which have values attached. The same principles apply, but the wording is different. For example,
A dead end has some text called the river sound. The river sound of a dead end is usually "a faint whispering of running water". The Tortuous Alcove has river sound "a gurgle of running water".
The property "river sound" is now applicable only to dead ends, so we would not be allowed to talk about "the river sound of the Savannah", say. Moreover, it's required to hold a piece of text. If we tried the following:
The river sound of the Tortuous Alcove is 7.
...then Inform would object, because the number 7 is the wrong kind of value to go into the "river sound" property. If we need a numerical property, we can try this instead:
A dead end has a number called the difficulty rating. The Tortuous Alcove has difficulty rating 7.
Suppose that we were to add:
The Exquisitely Narrow Defile is a dead end.
The Defile must have a river sound, of course, because we said that every dead end would have one. We haven't said what that river sound will be, but Inform can work it out, because we did say this:
The river sound of a dead end is usually "a faint whispering of running water".
If there are no instructions at all about the value of a property, Inform fills in the default value of the appropriate kind - in this case, it would be a blank text. (A table of the kinds which can be used for properties, and their default values, can be found in the Kinds index.)
For instance, if we want to give some objects a flavor:
"Would you...?"
The House is a room. The mouse is an animal in the House.
The player carries some green eggs and a ham.
A food is a kind of thing that is edible. Food has some text called flavor. The flavor of food is usually "Tolerable."
Things are, in general, not edible by default, so we have to make them edible specifically in order to allow them to be eaten by the player. Here we've defined food to be edible by default, and we have given it a standard piece of flavor text.
The ham and the green eggs are food. The flavor of the green eggs is "Delicious!"
After eating something:
if the noun provides the property flavor, say "[the flavor of the noun][paragraph break]";
otherwise say "It's [noun]-flavored."
Note that we use "if the noun provides a flavor..." to make sure that the property exists before attempting to use it. Otherwise, there is the risk that we will try to print a property that does not exist, resulting in errors in the game.
We will only get the "It's [noun]-flavored." response if we successfully eat something that is not a food and does not have flavor text. To test this feature, let's suppose something that isn't exactly food but can theoretically be chewed on:
The player carries some paper. The paper is edible.
Test me with "eat ham / eat green eggs / eat paper".
|
ExampleStraw Boater
Using text properties that apply only to some things and are not defined for others.
|
|
Sometimes we like to give properties to kinds of thing, but not fill them in in all cases. For instance, we might have vehicles that optionally make noise, and those might have a "movement sound".
All properties have a default value, which we can find by looking in the Kinds tab of the index. This is what the property will be set to automatically, if we do not change it ourselves. In the case of a text property, that is ""; so for instance we might use our movement sound thus:
"Straw Boater"
Boathouse is a room. "A boathouse circa 1915, which -- though in poor repair -- still suggests Sunday afternoon jaunts taken by women in white gowns and men in straw hats."
North of the Boathouse is the Shallow Water. The description of Shallow Water is "Just south is the boathouse, and beyond it are trees and the marble terrace of the house above. The water deepens to the north."
North of Shallow Water is Deep Water. The description of Deep Water is "From here the boathouse has dwindled invisibly to the south, and you have a broad panorama of the shoreline, all the way down to the Skeleton Point Lighthouse in the southeast."
A vehicle has some text called the movement sound. The sailboat and the motorboat are vehicles in the Boathouse. The movement sound of the motorboat is "VRRRROOOMMMM..." Understand "boat" as the sailboat. Understand "boat" as the motorboat.
Note that we haven't given the sailboat any movement sound at all.
After going somewhere by a vehicle (called cart):
if the movement sound of the cart is not "", say "[the movement sound of the cart][paragraph break]";
continue the action.
Instead of exiting when the player is in a vehicle and the location is not the Boathouse:
say "You're not dressed for a swim."
Instead of going somewhere when the player is not in a vehicle:
say "You'd rather not try to make this journey by swimming alone."
Test me with "n / get in sailboat / n / get out / s / get in motorboat / n / n".