[I7] Are activities the preferred solution?

I thought I’d augment the standard I7 behavior when it comes to examining supporters and containers. Since I wanted to retain the original behavior, I thought I’d use a rulebook.

Definition: a container is empty if nothing is in it.
Definition: a supporter is empty if nothing is on it.

The examination rules are an object based rulebook. The examination rules have default success.
An examination rule for something: rule fails.

First carry out examining a thing (called the item):
	follow the examination rules for the item;
	if rule succeeded:
		now examine text printed is true;
		rule succeeds.

Thing is, from reading the manual I get the sense the preferred solution would involve an activity as opposed to a rulebook. The code is after all general enough to be put into an extension (possibly). Is the use of activities appropriate, and if so, what benefits would they bring to the table?

The main advantage an activity has over a simple rulebook is that an activity brings along two extra rulebooks – before and after – which can be used as hooks for tweaking the behavior. This is especially useful for extension users. Having said that, since you’re calling the examination rules from the carry out examining rules, prospective users have plenty of hooks available to them already – namely the other rules involved in action processing. You didn’t post the code for your examination rules, but my guess is a regular rulebook is plenty.

ETA: BTW, I love this strategy (using object based rulebooks) – I’ve been using it for “fixed in place” messages, etc.

The other difference is that you can test whether or not activities are going on. So if you think code like The description of the foo is "[if the examination activity is going on]bar[else]baz[end if]". should be supported, activities would be a good choice.

Right, that’s what I figured. And usage would be as follows:

Definition: a container is empty if nothing is in it.
Definition: a supporter is empty if nothing is on it.

The examination rules are an object based rulebook. The examination rules have default success.
An examination rule for something: rule fails.

First carry out examining a thing (called the item):
	follow the examination rules for the item;
	if rule succeeded:
		now examine text printed is true;
		rule succeeds.


That Hideous Garden is a room. "You're surrounded by all manner of unwholesome plant life."

The venomous flytrap is a container. It is in the garden. Understand "plant" or "fly trap" as the flytrap. The description is "This plant is a pulsating, half-translucent, vaguely threatening sac of plant matter."

An examination rule for the empty flytrap: say "[description of the flytrap] It watches you hungrily, or at least it gives a good impression of doing so. Or maybe it's just bored."

An examination rule for the flytrap when the flytrap holds exactly one thing: say "[description of the flytrap] It seems barely satisfied with liquifying [the list of things held by the flytrap], but you're not sure how long the respite will last."

An examination rule for the flytrap: say "[description of the flytrap] Inside its bloated, half-transparent form you can see [the list of things held by the flytrap], being slowly digested."

The feed jar is a container. It is fixed in place in the garden. The description is "A big plastic jar stands here, obviously intended for the feeding of the monstrosities that grow here." In the feed jar is some seeds and an apple.

The player holds a coconut and a speckled egg.

Test me with "x jar/x flytrap/put coconut in flytrap/x flytrap/put egg in flytrap/x flytrap".

Yeah, it’s become my preferred method of extending behavior without trashing underlying functionality. That’s probably why I’m a bit mistrustful of it still, since I kept hearing how this kind of thing was supposed to be done through activities.

Right. I think I’m having a bit of a hard time seeing an eventuality where I’d need that, tbh. I know it’s a functionality people use, but try as I might I can’t think of any situation where it would be necessary.

I just realized that the example I posted worked when (and possibly only when) examining was defined with a rulebook rather than as an activity, so it’s totally off topic. Herp derp.

[rant]Well, there’s this:

For printing the name of the spider while examining the flytrap: say "unfortunate spider".

Which (once the spider has been defined) yields this:

Probably other ways to do that, though.[/rant]