Let's Play/Read: Inform 7 manuals (Done for now)

Chapter 9 - Time

This is one of a few smaller chapters in a row.

Section 9.1 is 'When play begins"

This just does things that only happen once, when the game starts:

When play begins: say "Welcome to Old Marston Grange, a country house cut off by fog."

The “when play begins” rules are checked only at the start of a story, not when a saved session is restored from disc. What happens is that these rules are followed, then the story’s banner is printed, then the initial room description is printed up, and then the player is asked for a first command.

Example 135 is Clueless, and shows how you can use ‘when play begins’ for stuff besides talking:

The murderer is a person that varies.

When play begins:
now the murderer is a random person who is not the player.

The Billiards Room is a room. Colonel Mustard and Professor Plum are men in the Billiards Room. Miss Scarlet and Mrs White are women in the Billiards Room.

Section 9.2 is Awarding points (which isn’t really a time thing?)

Having a score used to be a default, but now must be turned on manually:

Use scoring.

This enables in-game commands SCORE, NOTIFY ON and NOTIFY OFF and allows the author to award points at any time by this:
increase the score by 5;

I have mixed feelings on scoring. I used to squarely be in the ‘it’s outdated’ camp, but the nice thing about having a score is it really helps with pacing in a game; it makes it clear how long the overall game and how fast you’re progressing.

They warn not to let scoring actions happen over and over again (my current game doesn’t use the built-in score, but has a custom scoring thing for one section, and one beta tester found a way to get an unlimited score).

They give an example of scoring that can be abused by repeating the action:

After taking the trophy:
    increase the score by 5;
    say "Well done!"

and a similar one that can not be abused:

After taking the trophy when the trophy was not handled:
    increase the score by 5;
    say "Well done!"

(It is very important to note that this rule uses the past tense in its verb ‘was handled’; this is the first time we’ve seen this, where using the past tense refers to the game state at the beginning of the turn).

You can establish a maximum score as so:

The maximum score is 10.

And you can change the maximum score and current score at any time.

Example 136 is Mutt’s Adventure:

A room can be scored or unscored.

Carry out going to a unvisited scored room:
increment the score.

The Treasure Room is scored.

Example 137 uses tables for advanced scoring:

Table of Point Values

item score
cow 10
incantations 4
chessman 1
Report taking an item listed in the Table of Point Values:
    increase the score by the score entry;
    blank out the whole row.

‘Blank out the whole row’ is something we’ll see a lot more later on.

Section 9.2 is Introducing tables: rankings, which again has nothing to do with time. It just gives a way to make a table of rankings. ‘Rankings’ is a special name in Inform, and if made with a column called score with numbers and a column called rank made with text:

Score Rank
0 “Beginner”
25 “Amateur Adventurer”
50 “Novice Adventurer”
100 “Junior Adventurer”
200 “Adventurer”
300 “Master”
330 “Wizard”
350 “Master Adventurer”

Customarily, the score in the final row should be the maximum possible achieved in the story - so that only a player with maximum possible score can be awarded the final ranking - and the value of “maximum score” is automatically set to this bottom-row value if it has not been explicitly set anywhere else in the source text.

Section 9.4 is When play ends, which introduces some phrases for ending everything.

These includes:
end the story, which ends the game and prints ‘The End’, but it isn’t final (the game won’t print this like author’s notes, etc.)
end the story finally, which does the same as above but is considered final and prints final menu options

You can also change the printed message from ‘the end’ to anything else you want:
end the story saying (text)
or `end the story finally saying (text)'.

The book gives this example:

end the story finally saying "You have defeated Sauron"

The closing message is printed between three asterisks on left and right, and looks weird if it’s too long. I usually use a say " " command first to give most of the ending or death message, then end the story finally with one last sentence.

I always get errors because I tend to time ‘end the game’ instead of ‘end the story’.

We can check if the story is over as follows:

if story has ended
if story has not ended
if story has ended finally
if story has not ended finally

Any commands in ‘when play ends’ happen before the final message, like

When play ends, say "Oh dear."

Surprisingly, you can also just take back the ending with the command resume the story:

When play ends:
    if the story has not ended finally:
        say "Oh dear. Still, here's another chance.";
        resume the story.

Example 138 is Big Sky Country:

When play ends when the story has not ended finally:
    say "Oh dear, that ought to be fatal! However, if you like I can get you out of it...

    Shall I? >";
    if the player consents:
        repeat with item running through things had by the player:
            move the item to a random visited room;
        say "A strong wind picks you up and sets you back at [the location], though perhaps minus a few of your things.";
        resume the story;
        try looking.

This introduces if the player consents, which gives a special yes/no prompt.

Section 9.5 is ‘Every turn’.

Inform is a turn-based system, with one command giving one action taking one turn, in general.

There is a variable called turn count that is a number equal to the number of turns in play. It is turn 0 when the banner is printed and turn 1 whn the first command is typed.

At the end of the turn, you can make commands run with ‘Every turn’:
Every turn, say "The summer breeze shakes the apple-blossom."

Apparently this is equivalent to:
An every turn rule: say "The summer breeze shakes the apple-blossom."

but I don’t understand rulebooks so I’ll learn about that later.

I should say that Inform lets you see all rules running with RULES, but rules without names just print their conditions, and so if you use ‘every turn’ a lot (like I do) it’ll just say ‘every turn rule’ ‘every turn rule’ etc. with no further clarification. It helps to either name rules (which we’ll get to later) or just add conditions like:
every turn when the player is in spell-region, because that’s easier to pick out when debugging.

Example 139 is Witnessed:

A battery is a kind of thing. A battery has a number called charge. The charge of a battery is usually 15.

Every turn:
    repeat with hollow running through battery compartments:
        if the hollow is part of a switched on device (called the machine):
            if a battery (called cell) is in the hollow:
                decrement the charge of the cell;
                carry out the warning about failure activity with the machine;
                if the cell is discharged, carry out the putting out activity with the machine;
            otherwise:
                carry out the putting out activity with the machine.

Example 140 is a rare four-star example: Text Foosball.

I actually made a foosball table in my current game, and I wondered if Inform had a sample foosball table in its documentation, and it did!

I ended up not using this code because it heavily involves an NPC and mine doesn’t, but it’s really cool.

It has stuff like this:

Every turn when the ball is still and Joey is active:
    let total be Joey's score + score;
    if total > 9, make no decision;
    if the ball is unreachable, make no decision;
    now Joey is inactive;
    if a random chance of 1 in 2 succeeds:
        now the ball is approaching;
        say "Joey hits the ball solidly down towards your goal. Now it is [small white ball condition].";
    otherwise:
        say "Joey fails to hit the ball in your direction. It remains [small white ball condition]."

Section 9.6 is The time of day

This weirded me out when I first saw it but I like it.

Inform keeps an internal time tracker for games. Each game starts at 9 AM and every turn takes one minute.

This is great for timed games where the exact sequence of events happens every time you play it.

You can change the time of day any time you want:
The time of day is 3:13 PM.

You can say stuff like:

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."

This is the first time we’ve seen ‘at the time when’ that I can remember so far.

Example 141 is IPA:

When play begins: now the right hand status line is "[time of day]".

The time of day is 9:50 AM.

A shop is a kind of room. A shop has a time called the opening hour. The opening hour of the shop is usually 8 AM. A shop has a time called the closing hour. A shop usually has closing hour 6 PM.

Check going to a shop (called the target):
    if the time of day is before the opening hour of the target,
        say "[The target] is locked up until [the opening hour of the target]." instead.

Check going to a shop (called the target):
    if the time of day is after the closing hour of the target,
        say "[The target] has been closed since [the closing hour of the target]." instead.

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.

Section 9.7 is Tell the time:

The Clock Chamber is a room. "The dark chamber behind the clock face, a mill-room of gears which grind down the seconds. Through the glass you can see the reversed hands reading [the time of day]."

This prints numerals. To print words:
"Through the glass you can see the reversed hands reading [the time of day in words]."

You can also make the command prompt the time of day (not with any special syntax, just combining regular syntax):
When play begins: now the command prompt is "[time of day] >".

Example 142 is Situation Room.

To say (relevant time - a time) as 24h time:
    let H be the hours part of relevant time;
    let M be the minutes part of relevant time;
    say "[if H is less than 10]0[end if][H][if M is less than 10]0[end if][M]".

When play begins:
    now the time of day is 6:09 PM;
    now the right hand status line is "[time of day as 24h time]".

Section 9.8 is Approximate times, lengths of time

You can specify how rounded off to make the time:
The Clock Chamber is a room. "The dark chamber behind the clock face, a mill-room of gears which grind down the seconds. Through the glass you can see the reversed hands reading [the time of day to the nearest five minutes in words]."

Next we do a little type casting:

let X be 5;
if the player is in the Slow Room, now X is 10;
let deadline be the time of day plus X minutes

so X is a number but we turn it into a time. 1440 is the maximum time.

If we type ‘hours’ instead of ‘minutes’ it makes hours instead of minutes, which makes sense. 24 is the max of hours.

Section 9.9 is Comparing and shifting times:

The chronometer is in the Clock Chamber. “On one wall is a terribly self-important chronometer showing the time in major world cities. London: [time of day]. Paris: [one hour after the time of day]. Tokyo: [9 hours after the time of day]. Cupertino, California: [7 hours before the time of day].”

This shows how you can shift the time of day when printing.

You can also do it in conditions:
if time of day is before 11AM, etc.

Obviously since time is periodic, every time is both before and after every other time, but Inform restricts it to one day, and assumes days start at 4:00 AM.

Section 9.10 is Calculating times

You can split time up into the minutes part and hours part:

minutes part of 12:41 PM
hours part of 8:21 AM

And like early you can ‘cast’ any integer to a time by putting hours or minutes after it:

The clock error is a number that varies. To thump the mechanism: now the clock error is a random number from -10 to 10.

The broken grandfather clock is in the Chamber. "An erratic grandfather clock seems to say it is [clock error minutes after the time of day]."

When play begins, thump the mechanism. Instead of attacking the broken clock: thump the mechanism; say "You thump the clock, which now reads [clock error minutes after the time of day].".

This is just like python where you have a number n but you want to concatenate it onto a string so you ‘cast’ it with print("The number is" + str(n).)

Section 9.11 is ‘Future events’, which I’ve used before but always feels like a weird pseud-way of making scenes, like a parallel development that was discarded.

 Instead of pushing the egg-timer:
    say "It begins to mark time.";
    the egg-timer clucks in four turns from now.

At the time when the egg-timer clucks:
    say "Cluck! Cluck! Cluck! says the egg-timer."

So this construction just lets you schedule things a certain amount of times in the advance.

This construction is great for making funny jokes in code (like ‘the goblin breakdances in five turns from now’), since you can just type anything.

I used it a ton in The Magpie Takes the Train, which was a one-room game with a lot of schedule events:

To say ParrotSing:
	now the parrot is musical;
	the musicing ceases in three turns from now;
	
At the time when the musicing ceases:
	say "Horus stops singing and preens his feathers. He seems eager to sing again.";
	now Music is not TargetGiven;
	now the parrot is not musical;
	say "[line break][bracket]Renewed topic for the parrot - [bold type]Music[roman type][close bracket][line break]";

Every turn:
	if the parrot is musical:
		say "Horus is currently singing at the top of his lungs[if the parrot is offended], but he's glaring at you while he does it[end if].";

You can phrase it in minutes or in turns (which are minutes by default) or for specific times of day:

the egg-timer clucks in 18 minutes from now;
the egg-timer clucks in four turns from now;
the egg-timer clucks at 11:35 AM;

These are all used inside of other rules. If you know a specific time you can just declare it as its own rule (don’t know if this is a technical ‘rule’ but it’s like them):

At 4 PM: say "The great bells of the clock tower chime four."

It says that the scenes index lists these. Let’s try this with a sample game:

Adding:
At 9:03 AM: say "The rooster crows".
to a sandbox game makes the following appear in the index:

Note that I got an error the first time I tried this because I didn’t type ‘AM’.

Lots of examples!

Example 143 is MRE, with a hunger timer:

Food is a kind of thing. Food is usually edible. Food has a time called the satisfaction period. The satisfaction period of a food is usually 5 minutes.

A person can be hungry or replete. The player is hungry.

The Larder contains an apple, a candy bar, and a large plate of pasta. The apple, the candy bar, and the pasta are food. The satisfaction period of the apple is 2 minutes. The satisfaction period of the pasta is 125 minutes.

Carry out eating something:
    now the player is replete;
    hunger resumes in the satisfaction period of the noun from now.

At the time when hunger resumes:
    starvation occurs in three minutes from now;
    now the player is hungry.

At the time when starvation occurs:
    if the player is hungry, end the story saying "You have starved".

I noticed they changed ‘carry out’ here. Wouldn’t that get rid of regular eating rules, and not delete the object? Let’s try it out.

Huh, compiling this example, the apple does go away. Does adding our own ‘carry out’ rules just stack with older carry out rules instead of replacing them completely?

Example 144 is Totality:

At the time when the penumbra appears:
    say "The sunlight dies away to an eerie, brownish penumbra."

At the time when the eclipse begins:
    say "The moon passes across the disc of the sun, plunging the world into darkness.";
    now the Chamber is dark.

At the time when the eclipse ends:
    say "The moon passes away from the sun, and a gloomy penumbral light returns.";
    now the Chamber is lighted.

At the time when normal sunlight returns:
    say "The sun shines once more bright in the sky, not to be eclipsed again on this spot for another thirty-seven years."

To schedule an eclipse for (totality - a time):
    the penumbra appears at two minutes before totality;
    the eclipse begins at totality;
    the eclipse ends at three minutes after totality;
    normal sunlight returns at five minutes after totality.

‘To schedule an eclipse’ is an example of a Phrase.

Example 145 is Empire:

At 4:45 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train]!";
    now the station of the Train is the Train.

At 5:10 PM:
    now the station of the Train is Edmonds;
    if the player is in the train or the player is in the station of the train, say "The train pulls into Edmonds and comes to a stop."

At 5:17 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train], running north along the shore towards Everett.";
    now the station of the Train is the Train.

I’ve only reproduced a small part of this.

Example 146 is Hour of the Wren:

The player carries a card. The description of the card is "Typed: 'Active astrology - dislike your fortunes? change your stars! - make an appointment now - hour of the wren STILL AVAILABLE.'".

The time of day is 1:55 PM.

Understand "pick [time]" or "choose [time]" or "make appointment for [time]" or "make an appointment for [time]" as making an appointment for. Making an appointment for is an action applying to one time.

Carry out making an appointment for:
say "Fate cannot be commanded more than once."

Instead of making an appointment for the time understood for the first time:
say "You settle on [the time understood] for your appointment. The woman makes a note of it in an appointment book, which she carries in a brown paper bag. 'Excellent choice, ma'am,' she says in a low, urgent voice. 'You'll be very satisfied.'";
stars shift at the time understood.

Understand "hour of the wren" as 2:00 PM.

At the time when stars shift:
end the story saying "insert cataclysm here".

Section 9.12 is Actions as conditions:

We can use actions as conditions, like this:
if we are taking a container, ...
or the abbreviated form:
if taking a container, ...

I didn’t know this! I always did ‘if the current action is the player looking’ or ‘if the current action is looking’. This is similar but slightly more natural, which is nice.

You can also use the past tense:
Instead of waiting when we have taken the lantern, say "No, your acquisitive nature is roused now, and simply waiting will no longer do."

This only works if someone has ever successfully taken the lantern.

This past tense stuff is really heavy; I feel like it could be a massive game changer but I’m just learning it now.

Example 147 is Night Sky:
The Planetarium is a room. "[if we have examined the sinister message]A dark room where it seems something is about to jump out at you![otherwise]A tranquil dark room with a ceilingful of stars.[end if]"

There is also an example that doesn’t work since it uses ‘instead’ so the action that matters isn’t successful:
The sinister message is a thing in the Planetarium. "A message plays very softly, so that you would have to listen to hear it." Instead of doing anything other than listening to the message: say "It's only a sound, after all.". Instead of listening to the sinister message: say "A voice whispers, 'BEWARE'."

Example 148 is Zero:

Weight is a kind of value. The weights are light, manageable, and horribly heavy. Everything has a weight.

A thing is usually manageable.

Before printing the name of a horribly heavy thing (called weighty object):
    if we have taken the weighty object, say "[weight] ".

This includes ‘before printing the name of’, which to me is in the category of ‘mystical phrases I only see in random examples’.

Section 9.13 is past and perfect tenses.

There are three ways to do conditions in inform:
if X is Y...., which is what we’ve used the most.
if X has been Y' (which checks if X is Y has ever been true), and if X was Y` which only checks if X was Y at the start of the current turn

This is fantastic! I’ve rolled my own rules for this kind of thing many times, setting a flag at the beginning of every turn and then checking if the flag was still true at the end. This is great:

if the lantern was switched on, now the lantern is switched off;
if the lantern was switched off, now the lantern is switched on;

can be used for ‘push button’, for instance.

There is also the past perfect text which checks if ‘X has been Y’ was true at the beginning of the current action.

Do not say things like ‘if the noun has been open’, the manual warns, as ‘the noun’ is a variable phrase and when using ‘has been’ it checks past values of the noun.

Example 149 is Tense Boxing:

The mysterious box is in the Temporal Prism. It is an openable closed container.

To assess the box:
    if the box was not open, say "The box was not open.";
    if the box was open, say "The box was open.";
    if the box had not been open, say "The box had not been open.";
    if the box had been open, say "The box had been open.";
    if the box is not open, say "The box is not open.";
    if the box is open, say "The box is open.";
    if the box has not been open, say "The box has not been open.";
    if the box has been open, say "The box has been open."

Before opening the mysterious box:
    say "You are about to open the box.";
    assess the box.

Before closing the mysterious box:
    say "You are about to close the box.";
    assess the box.

After taking the mysterious box:
    if the box had not been carried by the player, say "You lift the mysterious box for the first time.";
    if the box had been carried by the player, say "You again pick up the mysterious box."

Example 150 is Brunesau’s Journey

Carry out burning the candle:
    now the candle is lit.

Report burning:
    if the candle had been lit, say "You relight the candle.";
    otherwise say "You light the candle for the first time.".

Carry out blowing out the candle:
    now the candle is unlit.

Report blowing out:
    if the noun is the candle and the candle was lit, say "You blow out [the noun].";
    otherwise say "You blow on [the noun], to little effect."

Example 151 is Elsie:

Every turn when the sliding door was open:
    now the sliding door is closed;
    if the player can see the sliding door:
        say "The sliding door slips back into place, sealing the wall as though there had never been a breach."

I wondered what would happen if you typed ‘close door’ when the door was open; would this rule fire anyway?

Yes, it does, but it fits in. It prints the following:

You close the sliding door.

The sliding door slips back into place, sealing the wall as though there had never been a breach.

In my current game I have the following:

Every turn when wax-doors are open:
	now wax-doors are closed;
	say "The double doors swing closed."

This has the negative effect of never letting the player open the doors without immediately closing. So I might switch to this new way.

Section 9.14 is How many times? This is some phrasing I’ve tried using but usually fail and just make some counter variable I increment myself:

if the player is in the Ballroom for the third time ...

This only works if the condition is true then false then true then false then true. So staying in the ballroom three turns doesn’t trigger it, but leaving and returning does.

You can also say:

if the player is in the Ballroom for more than the third time ...
if the player has been in the Ballroom three times ...

‘only’ and ‘exactly’ mean the same thing, so:
‘if the player has been in the Ballroom only three times …’

can be written. How is this different from not adding ‘exactly’? I don’t know. I think when using ‘has been’ that it defaults to ‘at least __ times’, so exactly avoids that. IDK though.

Examples 152 is Infiltration:
The Secure Zone has the description "[if the player is in the Zone for the second time]Re-entering the Zone has not made you any more comfortable inside. [end if]Despite your carefully-chosen outfit and the walk you have been practicing, you are sure those inside can tell you don't belong. Not that very many people are visible here[if the player is in the Zone for more than the second time] -- the place seems more desolate than ever[end if]."

Trying this example out, the first part of the message only prints the second time, and never again. The second part is ‘sticky’ and keeps printing.

If we change the first condition to if the player has been in the Zone two times, it plays the second time and every time after that.

Finally, 9.15 is How many turns?

This is for conditions that are holding now and the previous turn and so on:

if the floppy hat has been worn for three turns ...

This is an ‘at least’ kind of thing so will fire if it has been worn every turn for at least 3 turns.

You can instead say any of these three things to mean ‘exactly three turns’:

if the floppy hat is worn for the third turn ...
if the floppy hat has been worn for only 3 turns ...
if the floppy hat has been worn for exactly three turns ...

Again, we shouldn’t use variable nouns like ‘if the noun has been open’, since ‘the noun’ might have meant something in the past.

Every turn:
    if the player has been in the Minivan for 5 turns, say "'Are we there [if saying no]now?'[otherwise]yet?' asks Pete.[end if]"

Whew! Not the biggest chapter, but some pretty intense stuff.

4 Likes