Chapter 14: Units
14.11. Limits on the size of numbers

There are still some serious restrictions. Inform has only whole numbers, not floating-point (though we could in principle simulate at least fixed-point numbers by writing something like "10.99kg specifies a weight"). And in its normal setting (see below), Inform only allows numbers from -32768 to 32767. Since a London bus only weighs 7000kg, 32000kg is plenty: on the other hand, if we wanted to measure weight in grammes instead, the limit would be just 32kg, an amount which a human can just about lift.

The limit also begins to bite when using multiple-number specifications. Internally, Inform stores the above "running time" as a number of seconds, so that 3'59 is actually stored as 239. Calculating the maximum legal running time is a nuisance, so we can instead check the "Kinds" page of the index, where we read that:

running time (plural running times)
Written in the following form: 3'59
Maximum value allowed: 546'07

The maximum legal running time is therefore a little over 9 hours, so the new Tori Amos album will not be a problem, but some of the more punishing German operas might break the bank.

These restrictions are a nuisance, but can normally be managed, and we gain the ability to run the resulting work of IF on a very wide variety of computers indeed, some extremely small. If we do need larger numbers, we can change to the Glulx virtual machine (using the Settings panel), which buys us integers in the much larger range -2147483648 to 2147483647 but at the cost of being playable on fewer devices.


230
*** Example  Alias
A telephone with phone numbers of the standard American seven-digit length.

RB

Seven-digit telephone numbers are too long for Inform to handle when compiling to the Z-Machine, but they will work under Glulx. To have this example succeed, make sure that you have selected the Glulx option in your settings menu.

"Alias"

A telephone is a kind of thing. Understand "phone" or "telephone" as a telephone.

A phone number is a kind of value. 999-9999 specifies a phone number.

Now we borrow some techniques from the Understanding chapter to set up dialing actions:

Understand "dial [phone number] on [telephone]" as dialing it on. Understand "dial [phone number] on [something]" as dialing it on.

Understand the commands "phone" or "telephone" or "call" as "dial".

Understand "call [text]" or "phone [text]" or "dial [text]" or "telephone [text]" as a mistake ("That's not a number you know.").

Dialing it on is an action applying to one phone number and one thing.

Report dialing it on:
    say "You dial [the phone number understood]."

This much is enough to let us dial telephone numbers and have Inform report that we've done so; it doesn't actually provide a telephone system such that we could reach and converse with other characters (but see the other telephone examples in the recipe book for more on how one might do that).

We'll set up a little political espionage scenario from which our player can make calls:

The Senator's Junior Suite is a room. "The Senator appears, unfortunately, to have very precise habits: little in the room has been moved from its usual place; the trash can is empty; the bed has been remade[if the blue paper is unexamined]. There may in fact be nothing to find here[end if]."

The bed is enterable scenery in the Junior Suite.

The player is wearing a housekeeping uniform and a brunette wig. The player carries a telephone called a Nokia.

Borrowing again from the chapter on Understanding, we might arrange things so that the player knows and can call a few standard numbers with such syntax as CALL HOME:

Understand "home" as 555-9200.

And what if we'd like to have the player learn some phone numbers during the game?

A thing can be examined or unexamined. Carry out examining something: now the noun is examined.

Understand "Stephen" as 555-2513 when the blue paper is examined.

This will understand CALL STEPHEN once the paper is examined; before that, the player will just get the "That's not a number you know" response that Inform uses for all attempts to call unknown names.

We'd better plant this paper for the player to find:

The blue paper is in the drawer. The description of the blue paper is "It reads: 'Call Stephen - 555-2513'."

The drawer is part of the dresser. It is closed and openable. The dresser is in The Senator's Junior Suite. The lamp is on the dresser. The description of the dresser is "The single drawer is [if the drawer is open]open[otherwise]shut[end if]."

Test me with "dial 555-9999 / call home on the telephone / phone the president / call stephen / open drawer / read paper / call stephen / put phone in drawer / close drawer / call stephen".


PreviousContentsNext