Chapter 4: Kinds
4.12. Values that vary

Sometimes a value important to the simulated world will not naturally belong to any thing or room, and should not be kept in a property. For example:

The prevailing wind is a direction that varies. The prevailing wind is southwest.

Or "which varies" would also be allowed, as would the more traditional computing term "variable":

The target score is a number variable. The target score is 23.

In fact, we have seen a value that varies already: "location", which holds the room in which the game is presently taking place.

It's important to tell Inform what kind of value goes into the variable, as this will ensure that the wrong kind of value is never accidentally put into it. But just as for properties, we do not need to say explicitly what the initial value is: and if we do not, Inform will use the default value for its kind. (See the table in the Kinds index.)

We can have variables of any of the kinds of value, including new ones, but should watch out for a potential error. If we write:

The receptacle is a container that varies.

in a world which has no containers at all, Inform will object, because it will be unable to put any initial value into the receptacle variable. A similar complaint will be made if we write:

Colour is a kind of value. The fashionable shade is a colour that varies.

without ever having defined any colours. Something else we are not permitted is:

The receptacle is an open container that varies.

because the openness of a given container may change during play, so that the value in the variable might suddenly become invalid even though the variable itself had not changed.


52
*** Example  Real Adventurers Need No Help
Allowing the player to turn off all access to hints for the duration of a game, in order to avoid the temptation to rely on them overmuch.

RB

Suppose we have an action called "asking for help" that gives the player some hints on request. We've also made it possible to turn this feature off, if the player would like to discourage himself from using the hints too much. Now we need a value that varies to keep track of whether hints are currently permitted or currently not permitted. So we might write:

"Real Adventurers Need No Help"

A permission is a kind of value. The permissions are allowed and denied.

Hint usage is a permission that varies. Hint usage is allowed.

And under the right circumstances, we change hint usage to denied:

Check asking for help for the first time:
    say "Sometimes the temptation to rely on hints becomes overwhelming, and you may prefer to turn off hints now. If you do so, your further requests for guidance will be unavailing. Turn off hints? >";
    if player consents:
        now hint usage is denied;
        say "[line break]Truly, a real adventurer does not need hints." instead.

Then we can refer back to this value later to decide whether we want to display the hint menu or not:

Check asking for help:
    if hint usage is denied, say "You have chosen to eschew hints in this game. Be strong! Persevere!" instead.

Asking for help is an action out of world. Understand "help" or "hint" or "hints" as asking for help.

The Realm of Terribly Unjust Puzzles is a room.

Carry out asking for help:
    say "Fine, since you're weak enough to ask: here is a complete walkthrough: GET EGG. PEEL EGG. SMELL EGG. DIVIDE YOLK INTO THREE PORTIONS. GIVE THE SMALLEST PORTION OF YOLK TO THE GOLDEN GOOSE. ASK THE GOOSE ABOUT WHETHER THE SWAN IS TO BE TRUSTED. GIVE THE LARGEST PORTION OF YOLK TO THE SWAN. DANCE CONGA. EAT MEDIUM PORTION. STAND ON HEAD. WEST."

Test me with "hint".

Note that it would probably be kinder to offer the player some intermediate level of help, in the actual event.


PreviousContentsNext