How do you replace a rule that uses rulebook variables?

The standard way to replace one rule for another, in the current version of I7, is to use “substitutes for”. I want to modify the room description heading rule (which prints the name of a room when looking), so it seems like the solution would be:

This is the modified room description heading rule: […]
The modified room description heading rule substitutes for the room description heading rule.

Unfortunately, this doesn’t work. The room description heading rule relies on looking action variables, like “visibility ceiling”. If I write my rule outside of any rulebook (“this is the ___ rule”), it can’t access those.

Making my modified rule a “carry out looking” rule works fine, but then the “substitutes for” does nothing: it ends up at the end of the rulebook, printing the heading after the description. Making it a “check looking” rule and then unlisting it from the check looking rulebook just makes it never run at all.

What’s the proper way to go about this? I know I can unlist the room description heading rule, then manually put my rule in the proper place in the rulebook, but it seems like the more-elegant “substitutes for” system should be able to handle this.

1 Like

This is above my pay grade for the most part, but does the “X listed instead of Y in the Z rulebook” approach work here? Recipe Book link, scroll down to the “commit petty theft” bit.

1 Like

Was just about to suggest the same, but was too slow because I made a short test. :slightly_smiling_face:

Seems to work:

The Lab is a room. "This is the lab."

Carry out looking (this is the modified room description heading rule):
	say bold type;
	if the visibility level count is 0:
		begin the printing the name of a dark room activity;
		if handling the printing the name of a dark room activity:
			say "Darkness" (A);
		end the printing the name of a dark room activity;
	otherwise if the visibility ceiling is the location:
		say "[visibility ceiling] - nice!";
	otherwise:
		say "[The visibility ceiling]";
	say roman type;
	let intermediate level be the visibility-holder of the actor;
	repeat with intermediate level count running from 2 to the visibility level count:
		if the intermediate level is a supporter or the intermediate level is an animal:
			say " (on [the intermediate level])" (B);
		otherwise:
			say " (in [the intermediate level])" (C);
		let the intermediate level be the visibility-holder of the intermediate level;
	say line break;
	say run paragraph on with special look spacing.

The modified room description heading rule is listed instead of the room description heading rule in the carry out looking rules.

(The rule is taken from the Standard Rules, just modified to print “- nice!” after the room heading.)

Output:

Lab - nice!

This is the lab.

>

Docs link to WWI: 19.4. Listing rules explicitly

I think a special feature of “substitutes for” is that it can be used to make substitutions conditional, as in: The amulet carrying rule substitutes for the carrying requirements rule when locking something with the Amulet of Tumblers. (Though it can also be used without a condition.)

2 Likes

This compiles:

Carry out looking (this is the modified room description heading rule): say visibility ceiling.
The modified room description heading rule is listed after the declare everything unmentioned rule in the carry out looking rules.
The room description heading rule is not listed in any rulebook.

as does:

Carry out looking (this is the modified room description heading rule): say visibility ceiling.
The modified room description heading rule substitutes for the room description heading rule.

but in 10.1 rule substitutes for doesn’t work. The rule that’s getting replaced gets turned off, but the rule replacing it functionally doesn’t seem to get inserted. I7-2142

3 Likes