![]() | Chapter 4: Kinds | ![]() ![]() |
4.4. Duplicates |
Although it is only useful to a limited extent, we can make any number of copies of something:
"Polygons"
A shape is a kind of thing. A square is a kind of shape. A triangle is a kind of shape.
The Geometry Lab is a room. In the Geometry Lab are three triangles and two squares.
The description "three triangles" makes three identical things, each of the kind "triangle", and similarly for the squares. When the above is compiled, the player can type TAKE TWO TRIANGLES or TAKE ALL THE TRIANGLES and so forth. (The player has to type numbers as words when counting things here: so TAKE SIX TRIANGLES makes sense to Inform but TAKE 6 TRIANGLES doesn't, largely for traditional reasons.)
Three caveats. Firstly, a counted-out description like "two squares" is only allowed if it combines a number with the name of a kind which is already known (perhaps modified with adjectives, so "two open doors" is fine). If we say:
Two circles are in the Lab.
without having defined "circle" as a kind in advance, then only a single object will be created - whose name is "two circles". (This is because many natural names start with numbers: "six of clubs", for instance, referring to a single playing card, or "12 Hollywood Close" meaning a single house. We wouldn't want such names to be misinterpreted.)
The second caveat is that excessive duplication is expensive in memory and running time. It is perfectly legal to say
In the Lab are 75 triangles.
but the resulting game may be a little sluggish: and Inform draws the line at 100, refusing to create more duplicates than that in any single place. If we really need more than about fifty duplicated objects - say, a tombola containing raffle tickets numbered 1 to 1000 - it is usually better to find some less literal way to simulate this: for instance, only having a single raffle ticket, but with a randomly chosen number on it.
Finally: numbers up to twelve may be written out in words in the source text, but larger ones must be written as numerals. So "twelve" or "12", but "13" only.
| ![]() ![]() ![]() A child's set of building blocks, which come in three different colours - red, green and blue - but which can be repainted during play. |
|
Previous | Contents | Next |