Inform 7 Home Page / Documentation


§11.17. Phrases to decide other things

A condition is a yes/no decision, but we can also take decisions where the result is a value. Suppose we want to create a concept of the "grand prize", which will have different values at different times in play. Each time the "grand prize" is referred to, Inform will have to decide what its value is, and the following tells Inform how to make that decision:

To decide which treasure is the grand prize:
    if the Dark Room has been visited, decide on the silver bars;
    decide on the plover's egg.

Note that we have to say what kind the answer will be: here it's a kind of thing called "treasure" (which we're supposing has already been created), and as it turns out only two treasures are ever eligible anyway (we're also supposing that the plover's egg and the silver bars are treasures already created, of course). And note also that the phrase must in all cases end with a "decide on ..." to say what the answer is:

decide on (value)

This phrase can only be used in the body of a definition of a phrase to decide a value. It causes the calculation to end immediately, with the outcome being the given value, which must be of the kind expected. Example:

To decide which number is double (N - a number):
    let D be N times N;
    decide on D.

Now that we have "grand prize" created, we can use it just as we would use any other value, so for instance:

if taking the grand prize, ...

As this is something of a dialect difference between English speakers, "what" and "which" are synonymous here, i.e., we could equally well write something like:

To decide what number is the target score: ...

(A phrase to decide if something-or-other is exactly the same thing as a phrase to decide a truth state, and indeed, if we want to then we can use "decide on T", where T is a truth state, in its definition. For instance:

To decide if time is short:
    if the time of day is after 10 PM, decide on true;
    ...
    decide on whether or not Jennifer is hurried.

"Decide on true" is exactly equivalent to the more normally used "decide yes", and of course it is optional. The last line is more interesting since it effectively delegates the answer to another condition.)


arrow-up.png Start of Chapter 11: Phrases
arrow-left.png Back to §11.16. New conditions, new adjectives
arrow-right.png Onward to §11.18. The value after and the value before

*ExampleWitnessed 2
A piece of ghost-hunting equipment that responds depending on whether or not the meter is on and a ghost is visible or touchable from the current location.

***ExampleA Haughty Spirit
Windows overlooking lower spaces which will prevent the player from climbing through if the lower space is too far below.