Chapter 14: Units
14.16. Review of Chapter 14: Units

1. Numbers numbers may be manipulated by arithmetic with the forms either spelled out or represented as symbols:

the score + 10
100 - the score
10 * 21
144 / 12
the score plus 10
100 minus the score
10 times 21
10 multiplied by 21
144 divided by 12

We may change numbers that vary using "change" or "now"; the short hand "increase... by..." and "decrease... by..." allow us to do addition and subtraction a little more efficiently, as well:

change the score to the score + 10;
now the score is the score plus 10;
increase the score by 10;
decrease the score by 10.

2. Adjectives and comparatives. We can define adjectives that describe properties falling within a certain range, like so:

Definition: A container is large if its carrying capacity is 10 or more.
Definition: A container is standard if its carrying capacity is 7.
Definition: A container is small if its carrying capacity is 5 or less.

Then we can make comparisons and look for the most extreme examples of things:

if the basket is larger than the thimble ...
if the thimble is not larger than the basket ...
if the bag is the same carrying capacity as the basket ...
if the thimble is smaller than the basket ...
if the thimble is the largest visible container ...
let the current container be the smallest container carried by the player.

3. Units can be specified like this:

A weight is a kind of value. 10kg specifies a weight.

Price is a kind of value. $1.99 specifies a price. [default $0.00]
Price is a kind of value. $1.99 specifies a price with parts dollars and cents.
Price is a kind of value. $1.99 specifies a price with parts dollars and cents (optional, preamble optional).
An aspect ratio is a kind of value. 16:20 specifies an aspect ratio with parts width and height.

If we define a unit with parts, we may then refer to these parts separately:

dollars part of the price of the apple
cents part of the price of the apple

Once a unit has been defined, we can understand this unit in the player's input.

Understand "sell [something] for [price]" as selling it for.

(For more about Understand sentences, see the chapter on Understanding.)

4. We can also perform arithmetic on units, and tell Inform how multiplication turns units into other units:

the total weight of things on the platform divided by the number of things on the platform

if the price understood is less than $0.50...
if the price of the apple is more than $5.00, ...
decrease the price of the apple by $0.50

A length times a length specifies an area.


PreviousContentsNext