![]() | Chapter 11: Phrases | ![]() ![]() |
11.18. The value after and the value before |
Arithmetic is fundamental to most systems for computer programming: with Inform that is less true, so we only now come to the first mention of the addition of numbers. As might be expected, "+" can be used to combine two number values into one:
change the score to the score + 4
(This can also be spelled out "plus": or we could have written "increase the score by 4". Similarly, we can "decrease".) Inform generally expects to apply addition only to two numbers, so we cannot normally apply "+" to values like these:
Colour is a kind of value. The colours are red, orange, yellow, green, blue, indigo and violet.
There will be more about arithmetic on new kinds of value in the chapter on Units, but it may be useful to note that although we cannot (ordinarily) add up colours, we do automatically have two ways to make new colours from old:
the colour after C
the colour before C
produce the next, and the previous colour respectively, in order of their declaration. Thus "the colour after red" is orange; "the colour before blue" is green. The values wrap around, that is, "the colour before red" is violet and "the colour after violet" is red.
We are also allowed to use number-like comparisons with new kinds of value. Thus "red < yellow" is true, while "green >= violet" is not. Again, more on comparisons in the chapter on units.
| ![]() All objects in the game have a heat, but if not kept insulated they will tend toward room temperature (and at a somewhat exaggerated rate). |
|
| ![]() ![]() ![]() Turns take a quarter day each, and the game rotates through the days of the week. |
|
Previous | Contents | Next |