Inform 7 Home Page / Documentation
§9.6. The time of day
Inform keeps track of the time of day automatically: play ordinarily begins at 9 AM and each turn takes one minute. In some works of interactive fiction, time of day is crucial: in others, it is irrelevant or even, by a sort of tacit convention, non-existent. So Inform does nothing to act upon the time, or to reveal it to the player, without instruction. Nevertheless it is there.
A sentence like the following allows the initial time to be set up as something other than 9 AM:
The time of day is 3:13 PM.
Here, "3:13 PM" is a constant value of a kind not seen before: it's a kind of value called "time", and the value "time of day" is a time that varies. After one turn it will be 3:14 PM, then 3:15 PM and so on.
Note that the sentence above is an assertion (a statement about the initial state of affairs), not an instruction which can be part of a rule. It would be equivalent to write:
When play begins: now the time of day is 3:13 PM.
We more often change "time of day" to take care of drastic events:
At the time when the player loses consciousness:
now the time of day is 10:12 AM;
say "A mist comes over your vision, and when you come to, it is morning and you are in bed."
Suppose we wanted a game set in a living town, with locations opening and closing at different times of day, and business carrying on as usual. The point might be to force the player to plan his itinerary carefully to hit the right spots at the right times; or we might be writing a more contemplative piece, where part of the enjoyment came from just watching the characters wander around doing their daily business...
Every turn when the location is a shop:
let deadline be the closing hour of the location;
if the deadline is before the time of day:
let target be a random adjacent room which is not a shop;
say "You are gently but firmly ushered out, since [the location] is closing.";
move the player to the target.
The Strip-mall Parking Lot is a room. "Dead Christmas trees are heaped outside the bagel shop. Strips of dirty ice survive along the curb, and in the shadows of the lamp-posts. A wet, almost illegible sheet of algebra homework is plastered to the asphalt.
Pinewood Brewing Supply is a shop. It is east of Parking Lot. The opening hour of Pinewood Brewing Supply is 10:00 AM. The closing hour of Pinewood Brewing Supply is 3:30 PM. "Shelves and shelves of malt and hops; large glass carboys, and plastic tubing; empty bottles; bottle-caps; bottle-labeling kits; starters for vinegar, sourdough, root beer.
Instead of going to Brewing Supply when the time of day is before the opening hour of Brewing Supply for the second time:
say "You rattle at the door again. 'Hold your horses, for crying out loud,' yells a voice from within."
Noah's Bagels is a shop. It is north of the Parking Lot. The opening hour of Noah's Bagels is 6:00 AM. The closing hour of Noah's Bagels is 11:00 AM. "The selection has been somewhat picked over, leaving you with your choice of Pumpernickel, Asiago, or Everything."