It is very rare to find attributes that are the opposite of each other, because if you think about it, it's kind of a waste. Since they represent an either/or condition, if an object isn't one, it must be the other. Therefore, if you can't seem to find an "alive" attribute, perhaps you should look for a "dead" attribute. After all, you could describe something that's alive by saying "it's not dead." (Don't go looking for either of these attributes, however. I just made them up for example.) To demonstrate a real attribute, either an object provides light or it doesn't. If it does, it has the light attribute. If it doesn't, it doesn't. There is no "dark" attribute. (Gee, imagine Darth Vader saying, "Luke, you don't know the power of the not light side of the Force.")
Attributes are listed in an object's has clause and are not separated by commas.
If you want the player to be able to see anything in your game, at least one
object must be given the light attribute. (And of course that object has
to be somewhere near the player. "Near the player" is the subject of
an entire chapter.) If you don't want any darkness in the game whatsoever, give
the player object light. The best place to do this is in the
[Initialise; give player light; ... ];As you can see from above, if an attribute is to be given to an object outside of its definition, it is done with the give statement. And just like attributes, the give statement doesn't have an opposite. (There is a remove statement, but it does something else.) In order to take away a property, you give the object "not property." The symbol (called an operator) for not is ~ (tilde). To plunge BoringRoom into total darkness, you would issue this command:
give BoringRoom ~light;It may not seem very intuitive at first, but you'll get used to it.
It's important to know about real_location in case you want to move objects in or out of the room the player is actually in. (See the next chapter for information on moving objects.) If you simply move an object to location while it's dark, the object ends up in thedark, and is only usable when the player is there. Interesingly, any items actually located in thedark are visible. It's kind of strange to see output like
It is pitch dark, and you can't see a thing. You can see a table here.Come again? Don't worry, this won't normally happen. The Library handles placing dropped objects into real_location, not thedark, so something will enter thedark only if you explicitly make it do so through code. However, since there are times when you will do just that, you should check location and take special steps if it is thedark. Sometimes this will be a non-issue, though, and I'll cover these situations in a later example.
Attribute explosive;
Object Dynamite "stick of dynamite"
with name "stick" "dynamite"
has explosive; [footnote 1]
You can later test items to see if they "have explosive" to decide what to do when they are thrown.
< Previous page Contents Next page >
And yes, folks, it's really free. I'm too cheap to pay for this.