| ||
When you read the Designer's Manual, if you don't know that the British call a period a "full stop," now you do. |
The dot is equivalent to an apostrophe-s ('s) in English: it indicates possession. I would refer to my properties thus:
JeffJohnson.height JeffJohnson.HomeCountry(I left out name because it's a special value called an array, and I'm not ready to talk about them yet.) If you take the analogy and replace the dot with 's, the properties become JeffJohnson's height and JeffJohnson's HomeCountry. That looks easy enough, right? Now, let's say I want to avoid the Draft:
JeffJohnson.HomeCountry = "Canada";"How's it going, eh?" It's that simple. (Well, not really. Canada doesn't accept Draft dodgers anymore, but then again, we don't have the Draft anymore, either. But I digress....)
We could also put me on the rack and make me taller:
JeffJohnson.height = JeffJohnson.height + 2
Ouch.
So far we have assigned both strings and numbers to properties (as well as an array, but arrays either contain strings or numbers anyway). It's also possible (and common) for certain properties to hold references to rooms, which we indicate by specifying the room's constant. We'll see this when we add the second room to the file, assuming I ever stop talking about the first one. There is one more thing we can assign to a property: a routine. I know I haven't talked about them yet (wait until we get to the Initialise line), but I'll give a sample here. Suppose I have another property: HomeAddress. I may want to give out a different address depending on who's asking. I might have a routine with this logic:
If the person wanting my address in an IRS agent, return "111 Avenida del Sol, Tijuana, Mexico," otherwise return my real address.
As with many things in Inform, the library already has a set of predefined properties which it uses for different purposes. Two of these are used in BoringRoom: name and description.
with name "baseboard" "wood" "panelling" "panel", description "This room is empty. There is nothing here but the wood panelling on the walls and the baseboard."
Properties are defined after the with keyword and are separated by commas. No comma is used after the object header, however. Note the final comma at the end. This is necessary because the object has another clause, a has clause. If the object had ended here, like the first time when the room was dark, there would have been a semicolon instead of a comma.
name
When used in a room, the name property has a different meaning than
you would think. Instead of providing a set of words the player can use to
refer to the room, it actually provides a list of words which the player
never needs to use. You usually do this when you put things in the
room's description that are just for show and don't need to be picked up,
examined, or anything else. The wood panelling and the baseboard are two
such things. They are things you would logically find in a room, but the
player doesn't need to concern himself with them. (Normally you wouldn't
put such mundane objects into a room description, as seasoned I-F players
will examine everything you describe, assuming it serves some function.
Of course, if you're just trying to throw up a smokescreen....)
When used with a non-room object, the name property does exactly what you would expect it to: it provides a set of words which refer to the object. Break out each word individually. Let me emphasize that:
Object VelvetStool "velvet-covered footstool" with name "velvet" "covered" "velvet-covered" "footstool" "stool";Try to anticipate all the ways the player might type the name of the object, and include everything you can think of. Notice how I didn't use "velvet covered" in the above definition. This is because the parser (I'm getting ahead of myself, I know; just trust me) considers a space to be a word separator, therefore it can never see "velvet covered" as a single word, and the values in the name property are compared to the individual words the parser extracts from the player's command.
In fact, the parser keeps matching words until it either runs out or finds a word that is not part of the name property. This means that you can type GET THE VELVET-COVERED FOOTSTOOL, GET THE FOOTSTOOL, GET THE VELVET COVERED, GET STOOL, or even GET THE STOOL COVERED VELVET FOOTSTOOL VELVET-COVERED STOOL STOOL and Inform will determine that you are referring to the object.
description
For rooms, description is what is printed when the player first enters the
room and whenever the player types LOOK. The Designer's Manual calls this the
"long ('look') description." I think that says it all.
For a non-room, this property provides the text that is printed when the player uses EXAMINE. If an object doesn't provide this property, you get the standard "you see nothing special" message. For both types of objects, this property can contain either a string or a routine. (Routines are getting mentioned a lot, aren't they? That's because that is where the true power of Inform lies. Other than being able to walk around and pick things up, games would be pretty static without routines. We're on our way.)
I will cover more properties as we go along. I'll mention one more thing before we look at attributes: remember when I said the circumflex (^) is used to represent an apostrophe (') in the name property? Well, here we are. If I had wanted to called the footstool "Jim's footstool," it would have looked like this:
Object JimsFootstool "Jim's footstool" with name "Jim^s" "footstool" "stool";
Okay, now on to attributes!
And yes, folks, it's really free. I'm too cheap to pay for this.