The Four Cheeses Example in Writing with Inform

I’m probably in over my head here, considering I am just setting out with Inform, but Example 226 in Writing with Inform, contains code for implementing phone conversations.

I was playing around with it, and noticed that if I call the pizza boy on the phone, and then type “Listen to boy” the rule for “reaching into a room” fires, and the game prints:

Though you’re on the line with the pizza delivery boy, you can’t physically reach to Potter’s Pizza.
The pizza delivery boy is waiting for you to carry on the conversation.

I don’t think it’s supposed to print the first of these lines, since of course listening to someone isn’t really reaching into a room.

The relevant code says:

[code][Second, though the existing reaching inside rules are adequate to stop us from touching the person on the other end of the line, the response that’s currently printed is a bit generic: it just says “You can’t reach into [the room containing the person].” Let’s add our own custom reply, instead:]

A rule for reaching inside a room (called destination):
if the other party of the player is enclosed by the destination:
say “Though you’re on the line with [the other party of the player], you can’t physically reach to [the destination].”;
deny access.

Before listening to someone when the player cannot touch the noun:
say “[The noun] is waiting for you to carry on the conversation.” instead.[/code]
I tried commenting out the custom reply rule, and when I do that, typing “Listen to boy” results in only the line about the boy waiting for me to carry on the conversation being printed, as expected. The game does not print “You can’t reach into the room” as it does when I type “touch boy.” This leads me to believe that “listening” to someone is not a verb that actually causes the player to “reach inside a room,” so I can’t figure out why the custom rule also fires along with the “waiting to carry on the conversation” part. Shouldn’t a rule for “reaching inside a room” be skipped for verbs that don’t count as reaching inside?

The custom reaching inside rule has to run to check whether the condition (the player cannot touch the noun) for the Before rule is satisfied. And when it runs, it prints the text you’re objecting to. An easy fix is to change the preamble to the before rule to “Before listening to someone when the noun is not in the location”.

(If the “instead” in the Before rule wasn’t there, the reaching inside rules would run again to check whether to allow the action, and you’d get the text a second time.)

I don’t know exactly why you don’t get the default “You can’t reach into Potter’s Pizza” when you lose the custom rule. Presumably the default “can’t reach into rooms rule” prints nothing unless it’s actually stopping the action, but I don’t know whether that’s in the rule itself, or embedded more deeply in the action processing mechanism. (I’m not sure where to look to find out that sort of detail.)

I’m pretty confused by this. The “listening to” rule ordinarily does require a touchable noun:

[code]Lab is a room. Office is a room.
George is a man in Office.

After deciding the scope of the player: place George in scope.[/code]

but if we replace the Reaching inside rules with a test code like this:

A rule for reaching inside: say "Testing reaching inside."; if the action requires a touchable noun, say "The action requires a touchable noun."

we get:

I’m not sure why “listen to boy” seems to be getting through the reaching inside rules in the second case.

It’s only going through the reaching inside rules in order to test whether the condition of the before rule holds. They don’t have a chance to cut off the action, since the before rules run before the accessibility rules in the action sequence.

Thanks for clearing that up!

In this case, then as you already more or less said we can solve the immediate problem by the reaching inside rule only print its special message when we’re not listening:

A rule for reaching inside a room (called destination) while not listening: if the other party of the player is enclosed by the destination: say "Though you're on the line with [the other party of the player], you can't physically reach to [the destination]."; deny access.

Actually I think there are other similar problems with the Four Cheeses example.

You’d probably have to make a kind of action for conversationalish stuff like listening and asking for and tweak the reaching rules accordingly.

“Ask boy for pizza” is tough in this case because it actually is getting parsed as “asking the pizza delivery boy for the pizza delivery boy”–the only objects with “pizza” in their name are the pizza delivery boy and the Potter’s Pizza room.