Predicting Timed Events

Hi,

I would like a phrase to execute before any timed event is triggered. So, I assume I need to detect when a timed event rule is ready to trigger. From what I’ve surmised, these events are stored in an I6 table, and I’ll need to access the Table to find out if any of the rules are ready to go off. I’m pretty sure we can’t do this with I7 (although there is a suboptimal approach that includes the last every turn rule and a condition like "if the time of day is … or the time of day is … "). So, what kind of I6 inclusion would determine whether an event is about to occur?

Thanks.

Neil

You’ll want to replace the timed events rule with a version that invokes your code.

The custom timed events rule substitutes for the timed events rule.

The custom timed events rule translates into I6 as "CUSTOM_TIMED_EVENTS_R".

Include (-
[ CUSTOM_TIMED_EVENTS_R i event_timer fire rule;
    for (i=1: i<=(TimedEventsTable-->0): i++)
        if ((rule=TimedEventsTable-->i) ~= 0) {
            event_timer = TimedEventTimesTable-->i; fire = false;
            if (event_timer<0) {
		(TimedEventTimesTable-->i)++;
		if (TimedEventTimesTable-->i == 0) fire = true;
            } else {
                if ((the_time >= event_timer) && (the_time < event_timer+30)) fire = true;
            }
            if (fire) {
                TimedEventsTable-->i = 0;
                FollowRulebook( (+ timed events preamble rule +) );
                FollowRulebook(rule);
            }
        }
    rfalse;
];
-).

This is the timed events preamble rule:
	say "A timed event is about to occur."

This catches “At the time when…” events and “At X:YY…” events, but not every-turn events.