Inform 7 Home Page / Documentation


§17.14. Tokens can produce values

The examples just seen were tokens which simply matched specific words typed by the player, but newly created tokens can also produce values:

Colour is a kind of value. The colours are red, green and blue. Understand "colour [a colour]" or "[a colour] shade" as "[tint]".

Here the "[tint]" token matches, for instance, "colour red" and "blue shade", which would result in the values red and blue, respectively.

Tokens are not allowed to produce more than one value, and if several patterns are given to define them then those patterns have to be compatible. That means the following is disallowed, since it might work out to a colour, or to an object, leaving Inform unable to judge whether an action can safely be applied to the result.

Understand "colour [a colour]" or "[something]" as "[tint]".


arrow-up.png Start of Chapter 17: Understanding
arrow-left.png Back to §17.13. New tokens
arrow-right.png Onward to §17.15. Understanding things by their properties