5.4. Text with numbers

| Chapter 5: Text |

| 5.4. Text with numbers

When a numerical value is given in a square-bracketed substitution, it is ordinarily printed out in digits. Thus:

> "You've been wandering around for [turn count] turns now."

might print as "You've been wandering around for 213 turns now.", if the game has been played out for exactly that many commands. But if we prefer:

say "[number in words]"

This text substitution writes out the number in English text. Example: "You've been wandering around for [turn count in words] turns now." might produce "You've been wandering around for two hundred and thirteen turns now." The "and" here is natural on one side of the Atlantic but not the other - so with the "Use American dialect." option in place, it disappears.

Either way, though, there is some risk of the following:

> You've been wandering around for one turns now.

We can avoid this using the special substitution:

say "[s]"

This text substitution prints a letter "s" unless the last number printed was 1. Example: "You've been wandering around for [turn count in words] turn[s] now." produces "... for one turn now." or "... for two turns now." as appropriate. Note that it reacts only to numbers, not to other arithmetic values like times (or, for instance, weights from the "Metric Units" extension).

This only solves one case, but it's memorable, and the case is one which turns up often.

60
| Example Ballpark A new "to say" definition which allows the author to say "[a number in round numbers]" and get verbal descriptions like "a couple of" or "a few" as a result. |
RB

> Sometimes it is more sensible to describe numbers roughly than in exact terms. For instance, we might want to have our player perceive "many people" rather than "forty-two people" on entering a room. To achieve this, we might write our own "to say" phrase. "Ballpark" To say (count - a number) in round numbers: repeat through the Table of Numerical Approximation: if count is less than threshold entry: say "[approximation entry]"; rule succeeds. Phrases will be explained more thoroughly in a later chapter, but as we have already seen in the examples, we can make a "To say..." phrase that will allow us to create our own text substitutions. In this case, we are going to replace the specific number with a vaguer one chosen from a chart, so: Table of Numerical Approximation
> threshold | approximation
> 1 | "no"
> 2 | "one"
> 3 | "a couple of"
> 6 | "a few"
> 11 | "some"
> 21 | "many"
> 1000 | "lots and lots of"
The idea here is that we will work our way through the table until we hit a line where the threshold number is higher than the number we want to express, and then print that output: so if we have less than one item, we'll print "no"; if we have more than none but less than two, we'll print "one"; if we have less than three, we'll print "a couple of"; if we have three, four, or five (but not six), we'll print "a few." A room has a number called the population. The population of a room is usually 0. The description of a room is usually "You observe [population of the location in round numbers] [if population of the location is 1]person [otherwise]people [end if]here.". The Stadium is a room. The Hot Dog Stand is west of the Stadium. The Women's Restroom is south of the Stadium. The population of the Stadium is 500. The population of the Hot Dog Stand is 3. The population of the Restroom is 750. Test me with "w / e / s".

Previous | Contents | Next