Inform 7 time bug

The documentation (§10.3. Using the Scene index) recommends this way to make a scene last 3 turns:

Train Stop ends when the time since Train Stop began is 3 minutes.

But if the scene began less than four minutes before midnight, this means it will never end!

The time of day variable in Inform 7 is the current game time in minutes since midnight. At midnight, it is 0. So if the Train Stop scene occurs a minute before midnight, it happens at time of day 1439. When time of day passes 1439, it goes back to 0, assuming the standard pace of 1 minute per turn. Then time since 1439 (when Train Stop began) will be -1439 minutes. The next turn it will be -1438 minutes. One minute before the next midnight, the time since Train Stop began will be 0. It will never be 3.

I’ll open an issue about this at the unofficial bug tracker as well.

EDIT: I suppose the simplest fix is to write Train Stop ends when the time since Train Stop began is 3 minutes or the time since Train Stop began is -1438 minutes.


I think that the following corrects for the issue that you’ve pointed out.

EDIT: Modified revised logic to be stylistically aligned with the other code that Zed mentions below.


! ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
! Time.i6t: Scene Questions (modified)
! ==== ==== ==== ==== ==== ==== ==== ==== ==== ====

[ SceneUtility sc task;
    if (sc <= 0) return 0;
    if (task == 1 or 2) {
	    if (scene_endings-->(sc-1) == 0) return RunTimeProblem(RTP_SCENEHASNTSTARTED, sc);
    } else {
	    if (scene_endings-->(sc-1) <= 1) return RunTimeProblem(RTP_SCENEHASNTENDED, sc);
    switch (task) {
	    1: return (the_time - scene_started-->(sc-1) + TWENTY_FOUR_HOURS)%(TWENTY_FOUR_HOURS);
	    2: return scene_started-->(sc-1);
	    3: return (the_time - scene_ended-->(sc-1) + TWENTY_FOUR_HOURS)%(TWENTY_FOUR_HOURS);
	    4: return scene_ended-->(sc-1);

-) instead of "Scene Questions" in "Time.i6t".

This clunkier phrasing works. I7 does have a facility to compare times that’s sensitive to wrapping around midnight; it’s just not using it there.

Train Stop ends when the time of day is 3 minutes after
the time when Train Stop began.

De-clunkifying that somewhat…

To decide if it's (t - a time) since (S - a scene) began:
    if the time of day is t after the time when S began, yes;

Train stop ends when it's 3 minutes since Train Stop began.

or better yet, just making the doc’s existing suggested usage work across midnight:

To decide which time is the time since (sc - scene) began:
    decide on time of day minus the time when sc began.

taking the train example to the letter, the specific issue (that is, arrival and departure time) has a solution since XIXth century, that is, absolute instead of relative time measurement, as everyone can check on an actual train timetable…

(dunno in other countries, but here in Italy, night trains sometimes actually arrive to major stations (ones with engine depot…) some minute before midnight, and depart some minute after midnight, for conveniently changing both engine and crew at end-shift)

Best regards from Italy,
dott. Piergiorgio.

1 Like