Inform 7 Home Page / Documentation
§11.16. New conditions, new adjectives
We can create new conditions by defining a phrase with "to decide whether" (or equivalently "to decide if"):
To decide whether danger lurks:
if in darkness, decide yes;
if the Control Room has been visited, decide no;
decide yes.
If the player is indeed in darkness, the decision is "yes" because the "decide yes" stops the process right there. We can now write, for instance,
In fact, "danger lurks" is now a condition as good as any other, and can be used wherever a condition would be given. Rules can apply only "when danger lurks", for instance.
yes
decide yes
This phrase can only be used in the definition of a phrase to decide whether a condition holds. It ends the decision process immediately and makes the condition true.
no
decide no
This phrase can only be used in the definition of a phrase to decide whether a condition holds. It ends the decision process immediately and makes the condition false.
We can also supply definitions of adjectives like this. So far, new adjectives have been defined like so:
Definition: a supporter is occupied if it is described and something is on it.
If we want to give a definition which involves more complex logic, we can use a special form allowing us to make arbitrary decisions. In this longer format, the same definition would look like so:
Definition: a supporter is occupied:
if it is undescribed, decide no;
if something is on it, decide yes;
decide no.
Here "it" refers to the supporter in question. Note that there are now two colons in this sentence, one after "Definition", the other after the clause being defined. But that apart, it's a phrase like any other: it must end in "yes" or "no" just as the "danger lurks" example must. "Decide no" and "decide yes" are needed so often that they can be abbreviated by leaving out "decide":
Definition: a supporter is occupied:
if it is undescribed, no;
if something is on it, yes;
no.
Start of Chapter 11: Phrases | |
Back to §11.15. Let and temporary variables | |
Onward to §11.17. Phrases to decide other things |
Owen's Law |