6.5. Defining adjectives for values

| Chapter 6: Descriptions |

| 6.5. Defining adjectives for values

In general, any noun can have adjectives applied to it, and this means that values can have adjectives just as objects can. We have already seen that they can (in some cases, at least) have either/or properties, and this gives them adjectives just as for objects. But we can also write out definitions which apply to values:

> Definition: A number is round if the remainder after dividing it by 10 is 0.
> Definition: A time is late rather than early if it is at least 8 PM.

That makes the numbers 20 and 170 but not 37 meet the description "a round number", and the times 8 PM and 11:23 PM but not 9 AM meet the description "a late time". Because they come up fairly often, Inform contains several adjectives for numbers built in:

> positive - one which is greater than zero (but not 0 itself)
> negative - one which is less than zero (but not 0 itself)
> even - a number like ..., -4, -2, 0, 2, 4, ...
> odd - a number like ..., -5, -3, -1, 1, 3, 5, ...

Similarly, two useful adjectives are built in to talk about text:

> empty - the text "", with no characters in it, not even spaces
> non-empty - any text which does have at least one character in

Adjectives can have multiple definitions and, as long as each applies to a different sort of noun, there will be no problem. We could write:

> A thing can be round, square or funny-shaped.
> A container can be odd or ordinary.

And these definitions of "round" and "odd" will not interfere with the ones applying to numbers, because Inform can always look at the noun to see which definition is meant in any given case. For instance,

> if the score is round, ...

must mean "round" in the sense of numbers, because the score is a number. Inform itself makes good use of this; "empty" also has meanings applying to rulebooks, lists and activities, for instance, as will be seen later.

Although it's more usual to give a definition to apply to a whole kind, we can actually give a specific definition to apply to just a single object or named value. For example:

> A colour is a kind of value. The colours are red, green and blue.
> Definition: red is subtle if the player is female.
> Definition: a colour is subtle if it is blue.

The first definition of "subtle" takes precedence, of course, since it has the more specific domain - it applies only to red. The effect of this is that, if the player's female, the subtle colours are red and blue; if not, just blue.

74
| Example Only You... Smoke which spreads through the rooms of the map, but only every other turn. |
RB

Previous | Contents | Next