Scheduled Activities by John Clemens


This extension allows activities to be scheduled at absolute and relative times. These activities may later be checked or cancelled. The advantage of this over the standard events is that activities may take a variable, and the same activity may be scheduled multiple times. Rudimentary support is also provided for grouping output of multiple activities scheduled for the same turn. The extension only allows for activities which are applied to objects or to nothing (i.e., it does not allow activities applied to other kinds of value).

Scheduled activities are stored in a table called the Table of Scheduled Events. This table initially holds 50 future activities; if more storage is needed, you can add a table continuation as follows:

Table of Scheduled Events (continued)
SA_Moment SA_Turn SA_Event SA_Object_Event SA_Target SA_Similar
a time a number an activity on nothing an activity on objects an object a number
with 100 blank rows

A new rule (the scheduled events rule) is inserted before the timed events rule (the rule which handles the usual timed events). So scheduled activities will occur immediately before events invoked with phrases like "the egg-timer clucks in four turns from now".

SCHEDULING: The extension provides the following phrases to schedule activities:

schedule (an activity) for (an object) at (a time)
schedule (an activity) at (a time)
schedule (an activity) for (an object) in (a number) minutes
schedule (an activity) in (a number) minutes
schedule (an activity) for (an object) now
schedule (an activity) now
schedule (an activity) for (an object) in (a number) turns
schedule (an activity) in (a number) turns

Here, "now" means at the end of the current turn.

CANCELING: Activities can also be canceled:

cancel all scheduled events for (an object)
cancel all scheduled events
cancel next timed event for (an object)
cancel next timed event
cancel all scheduled (an activity)
cancel all scheduled (an activity) for (an object)
cancel all scheduled events at (a time)
cancel all scheduled events for (an object) at (a time)

Note that "next timed event" considers only events scheduled in times, not those scheduled in turns. Also note that only activities scheduled with the phrases above can be canceled or checked in this way.

CHECKING: The following conditions are supplied:

if there is an event scheduled
if there is an event scheduled for (an object)
if there is (an activity) scheduled for (an object)
if there is (an activity) scheduled
if there is an event scheduled at (a time)
if there is an event scheduled for (an object) at (a time)
if there is (an activity) scheduled at (a time)
if there is (an activity) scheduled for (an object) at (a time)
if there is an event scheduled now
if there is (an activity) scheduled now
if there is an event scheduled for (an object) now
if there is (an activity) scheduled for (an object) now

REPORTING: Several conditions allow better reporting of multiple activities happening in the same turn.

if first current activity

This condition is true when carrying out the first scheduled activity during a given turn.

if first similar activity

This condition is true when carrying out a particular activity for the first time during a given turn (even if other activities have been carried out). This can be used to combine reports for carrying out the same activity with multiple objects in the same turn; see the example "Bunnies".

Note that these two conditions do not apply to skipped events caused by changing the time directly.

A new relation, the pending relation, is defined between objects and activities when the given activity is scheduled for the object during the current turn. So, for instance, the condition

if a rabbit is pending waking

will be true if the waking activity is scheduled for some rabbit during the current turn.

DESCRIPTIONS: Several phrases are included allowing object descriptions, so it is possible to say, for instance, "schedule dispersing in 5 turns for everything enclosed by the location." The included phrases are:

schedule (an activity) at (a time) for (a description)
schedule (an activity) in (a number) minutes for (a description)
schedule (an activity) now for (a description)
schedule (an activity) in (a number) turns for (a description)
cancel all scheduled events for (a description)
cancel all scheduled (an activity) for (a description)
if there is an event scheduled for (a description)
if there is (an activity) scheduled for (a description)
if there is an event scheduled now for (a description)
if there is (an activity) scheduled now for (a description)

Example: * Tinitinitis - Scheduling, testing, and canceling activities.

"Tinitinitis"

Include Scheduled Activities by John Clemens.

The Concert Hall is a room.

A percussive instrument is a kind of thing. A percussive instrument can be ringing. A percussive instrument has a number called duration. The duration of a percussive instrument is usually 5.

The cymbal is a percussive instrument in the concert hall.
The triangle is a percussive instrument in the concert hall. The duration of the triangle is 1.

Striking is an action applying to one thing. Understand "strike [something]" as striking.
Report striking: say "You strike [the noun]."

Instead of striking a percussive instrument:
     if the noun is ringing, say "You strike [the noun] again[if the noun is pending silencing], just in time[end if].";
     otherwise say "You strike [the noun] and it starts ringing.";
     now the noun is ringing;
     cancel all scheduled silencing for the noun;
     schedule silencing for the noun in duration of noun minutes.

Silencing something is an activity.
Rule for silencing something (called bell):
     if the bell is ringing, say "[The bell] stops ringing.";
     now the bell is not ringing.

Test me with "strike cymbal / strike cymbal / strike triangle / strike triangle / z / z / z".

Example: * Perfume - Using descriptions and rooms.

"Perfume"

Include Scheduled Activities by John Clemens.

A room is either smelly or unscented. A room is usually unscented.
A thing is either smelly or unscented. A thing is usually unscented.

Instead of smelling a smelly room: say "A horrible perfume odor assaults your nostrils."
Instead of smelling a smelly thing, say "You can still smell the perfume on [the noun]."

Living room is a room. Study is west of the living room. Kitchen is east of the living room.
A rare book, a newspaper, and a sweater are in the study.

The perfume bottle is in the living room. The description is "A perfume spray bottle."

Dispersing something is an activity.
Rule for dispersing a room (called place):
     if place is smelly and place is the location, say "The perfume haze finally clears.";
     now place is unscented.
Rule for dispersing a thing (called item): now item is unscented.

Understand "spray [something]" as spraying. Spraying is an action applying to one carried thing.
Check spraying: if the noun is not the perfume, instead say "You can't spray that."
Carry out spraying:
     cancel all scheduled dispersing for the location;
     cancel all scheduled dispersing for everything enclosed by the location;
     now the location is smelly;
     now everything enclosed by the location is smelly;
     schedule dispersing for the location in 2 turns;
     schedule dispersing in 5 turns for everything enclosed by the location.
Report spraying: say "You spray the perfume into the air, leaving a noxious haze."

Test me with "smell / spray perfume / smell / w /smell book / spray perfume / smell / smell book / smell / smell book / e / smell / w / smell book".

Example: ** Bunnies - Grouping activity reports.

"Bunnies"

Include Scheduled Activities by John Clemens.

When play begins, say "You have snuck into the castle to steal the King's scepter. You have heard tales of the fierce rabbits guarding the palace, but are armed with a supply of holy hand grenades."

A mood is a kind of value. The moods are asleep, suspicious, vicious, and mutilated.

Definition: a rabbit is living if it is not mutilated.

To say long mood of (bugs - a rabbit):
     if bugs is asleep, say "sleeping peacefully";
     if bugs is suspicious, say "eyeing you suspiciously";
     if bugs is vicious, say "snarling viciously";
     if bugs is mutilated, say "splattered on the walls".

A rabbit is a kind of animal. A rabbit has a mood. A rabbit is usually asleep. Understand the mood property as describing a rabbit. The printed name of a rabbit is usually "[mood] rabbit". The printed plural name of a rabbit is usually "[mood] rabbits".
Rule for printing the name of a rabbit (called bugs) while listing contents of a room: say "rabbit [long mood of item described]". Rule for printing the plural name of a rabbit while listing contents of a room: say "rabbits [long mood of item described]".

Instead of doing something to a mutilated rabbit, say "There's really not much left of it."

After going to somewhere:
     repeat with bugs running through rabbits in location begin;
         if bugs is asleep, schedule rousing for bugs now;
         if bugs is suspicious, schedule angering for bugs now;
     end repeat;
     continue the action.

Every turn when a vicious rabbit is in location:
     say "You are suddenly beset by sharp pointy teeth as [if the number of vicious rabbits in location > 1][the number of vicious rabbits in location in words] vicious rabbits lunge[otherwise]a vicious rabbit lunges[end if] for your throat.";
     end the game in death.

Rousing something is an activity.
Rule for rousing an asleep rabbit (called bugs):
     now bugs is suspicious;
     schedule angering for bugs in 1 turn;
     if first similar activity and a visible rabbit is pending rousing, say "Hearing you, the sleeping rabbit[if the number of visible rabbits pending rousing is 1] begins[otherwise]s begin[end if] to stir."

Angering something is an activity.
Rule for angering a suspicious rabbit (called bugs):
     now bugs is vicious;
     if first similar activity and a visible rabbit is pending angering, say "The suspicious rabbit[if the number of visible rabbits pending angering is 1] bares its[otherwise]s bare their[end if] teeth at you."

A holy hand grenade is a kind of thing. The player carries five holy hand grenades.

Understand "throw [holy hand grenade] [direction]" as lobbing it toward. Understand the commands "lob" and "lobbeth" as "throw". Instead of dropping a holy hand grenade, try lobbing the noun toward down.

Lobbing it toward is an action applying to one carried thing and one visible thing.

Check lobbing it toward: abide by the can't drop what's not held rule.

The target room is a room that varies.

Carry out lobbing it toward:
     if there is exploding scheduled for the noun begin;
         say "You throw the grenade";
     otherwise;
         say "You pull the pin and throw the grenade";
         schedule exploding for the noun in 2 turns;
     end if;
     now the target room is the room second noun from location;
     if the second noun is down, now the target room is location;
     if target room is not a room begin;
         say " [second noun], where it bounces off [if second noun is up]the ceiling[otherwise]the wall[end if] and lands at your feet.";
         move noun to location;
     otherwise;
         if target room is location, say " on the ground.";
         otherwise say " into [the target room].";
         move noun to target room;
     end if.

Exploding something is an activity.
Rule for exploding a holy hand grenade (called bomb):
     if bomb is in the location begin;
         say "[bold type]Boom! [roman type]The grenade explodes, killing you instantly.";
         cancel all scheduled events;
         end the game in death;
     otherwise;
         let destroyed be the location of bomb;
         if destroyed is a room begin;
             say "You hear an explosion from [the best route from location to destroyed][if a living rabbit is in destroyed], followed by the unmistakable sound of rabbit screams[end if].";
             now every rabbit in destroyed is mutilated;
             repeat with item running through holy hand grenades in destroyed begin;
                 cancel all scheduled events for item;
                 remove item from play;
             end repeat;
         end if;
     end if.

The Entrance is a room. "A Hall stretches to the east, and the exit is back west."
The Hall is east of the entrance. "The entrance is west, and the banquet room is south." In the Hall are five rabbits.
The Banquet Room is south of the hall. "The hall is north, and the throne room is west." In the Banquet Room are 3 rabbits and 1 suspicious rabbit.
The Throne room is west of the banquet room. "The treasure is stored here." In the throne room are two vicious rabbits.
The scepter is in the throne room. The description of the scepter is "Covered with jewels, and worth the risk."
Instead of going west in the Entrance: say "Not without the scepter."
Instead of going west in the Entrance when the player carries the scepter: say "You escape with the scepter, ensuring your fortune."; end the game in victory.

Test me with "e / lobbeth holy hand grenade / w / z / e / throw grenade s / z / z / s / throw grenade w / z / z / w / take scepter / e / n / w / w".

Test death with "e / s / n".

Section Changelog

version 10 January 10, 2022

updated for 6M62 by Zed Lopez

version 9 September 10, 2010

updated activity types for compatibility with 6E59/6E72 type checking
minor code cleanup

version 8 (May 11, 2009)

code cleanup
more explicit table column names to preclude conflicts
pending relation now behaves properly again

version 7 (May 8, 2008)

updated for compatibility with 5T18
updated documentation
minor code improvement

version 6 (date forgotten)

minor compatibility update

version 5 (August 11, 2007)

Updated for compatibility with 4W37
changed the Target column to SA_Target to avoid name-space conflict

version 4 (March 26, 2007)

Updated for compatibility with 4S08
Pending relation replaced with several phrase for compatibility with 4S08
Removed use of procedural rule
Changed skipped events checking to agree with Inform behavior for timed events (processes events less than 30 minutes before time of day)
Fixed bug to do with checking preceding similar activities

version 3 (October 1, 2006)

Note: This version requires at least compiler version 3Z95; if you are using an earlier compiler version you should use version 2.
"Thing" has been changed to "object", so activities can now be scheduled for rooms
Added phrases utilizing descriptions
Added example "Perfume"
Added syntax for "turn", "minute", and "turns from now"
Updated documentation
Updated example "Bunnies" for 3Z95
Minor tidying of code

version 2 (July 19, 2006):

Improved paragraph breaks between activities
Added the new syntax: schedule now
Added reporting conditions: if first current activity and if first similar activity
Added the pending relation
Added example "Bunnies"

version 1 (July 15, 2006): Initial version