Ordering timed events that take place on the same turn

Consider this source code:

[code]Soundstage is a room.
The time of day is 9:00 AM.
When play begins: change the right hand status line to “[time of day]”.

Instead of singing:
say “You begin a song that will last for three minutes.”;
the song ends in three minutes from now.

At the time when the song ends:
say “You finish singing.”

At 9:05 AM:
say “The spotlight comes on.”

Test me with “z/z/sing/z/z/z”.[/code]

The last two rules both fire on the same turn, yielding this:

How does Inform determine which one fires first? Is there any way to make the spotlight rule fire second?

Experimenting a bit, if we replace the “At 9:05 AM:” rule with this:

[code]When play begins:
the lights come on in five minutes from now.

At the time when the lights come on:
say “The spotlight comes on.”[/code]

the “lights come on” event still fires before the “song ends” rule. Is it that the event that is scheduled first fires first? Answer: no;

[code]At 9:04 AM:
the lights come on in one minute from now.

At the time when the lights come on:
say “The spotlight comes on.”[/code]

still has the lights come on first.

So, is there any way to control this, or any rhyme or reason to the scheduling?

Events are added to these tables at compile time in source code order, at runtime by finding the first matching or open slot and filling it.

So, in your first example, the 9:05 rule is added to slot 1 at compile time, then the finish singing rule is added in slot 2.

Likewise, in your second example, the spotlight rule is added to slot 1 at runtime, then the singing rule ends up in slot 2.

In your third example, the 9:04 rule occupies slot 1, the singing rule gets slot 2, the 9:04 rule fires, opening slot 1, and then the spotlight rule reclaims slot 1.

It would not be hard for an I6 coder to write an extension to manage this behavior; I would do it, but I’m tight on time until this weekend.

Thanks! In the meantime, maybe I’ll use an Every turn rule for the event that’s supposed to fire first, or just leave them in a slightly wrong order (it’s not that big a deal).

The extension “Phrases for Adaptive Pacing” might have some bits you could play with to put things in order.