version 3 by Gavin Lambert
For suggestions and feedback, Gavin Lambert can be contacted via "http://www.mirality.co.nz/".
Inform provides the ability to define named rules for specific events. The included example is an expansion of the example shown in the manual (chapter 9.11 as of this writing) that uses some of the new phrases defined in this extension.
The new phrases defined here are:
say (a time) as a duration
the total number of minutes in (a time)
the interval between (a time) and (another time)
the number of turns until (some event)
the time when (some event)
the time until (some event)
if (an event) is/are scheduled
if (a time) is invalid
Most of these should be fairly self-explanatory (at least after looking at the example), except perhaps for the last two. Inform only remembers events up until they occur (which is why there is no "time since (some event)" in this list), which means that an attempt to request "the number of turns until the bomb explodes" will fail if the bomb has already exploded or if the bomb hasn't started ticking yet. The "number of turns" phrase reports failure by returning a negative number of turns; the time phrases do the same, but since this is harder to test for, the "is invalid" phrase is provided as a convenience. This will be true if the time is negative, and hence whether the event could be found or not. If you're using these phrases within "say", though, it's better to test for "if event is scheduled" beforehand to avoid running into this.
The "total number of minutes" is only really useful for intervals or durations, not absolute times. But this can be handy if you want to do maths involving intervals longer than an hour.
The "interval between" two times assumes that the second time is after the first. If you pass them the other way around, then you will get a negative interval.
One more caveat: due to the way that Inform's processing structure works, the prompt and status line represent the turn that the player is about to make. This means that anything shown there will be one turn/minute less than anything shown prior to that, and the same as anything shown during processing of the player's about-to-be-entered command.
By default, during the turn (or when printing the prompt/status at the start of the turn) that the event occurs, the time is equal and the interval is zero. If you prefer having the last turn count returned be one instead, then you can "Use one-based turn reporting", which will change this. (I think it looks really weird when doing that, but some people might prefer it.) Note that using this option will make the count shown in the turn the timer is started be one higher than it ought to be. Try it with the egg timer example and see.
Also, it assumes that one turn is one minute, in order to return sensible values in cases such as having started a "turns" timer and then asking what time it finishes. While this is standard in I7, and there is no standard way to alter this from I7, the underlying I6 code does admit to the possibility of a different clock rate. So if you've changed that somehow then you could run into trouble. And of course there'll be a mismatch between turns and time whenever you manually change the time to something else.
(For historic reasons, "if event is scheduled" can also be written as "if scheduled event". This latter phrasing might be removed if I update this extension again.)