You can't hear any such thing

How can I get Inform 7 to say “You can’t hear any such thing” when they try to listen to something that isn’t there? “You can’t see any such thing” is the default response. It makes no sense!

Thanks for reading.

if there’s an “unknown object”, the standard response will always be “You can’t see any such thing” when trying to interact with it. Maybe one of the more experienced folks know how to over-ride that.

You want to use a rule for printing the “can’t see any such thing” parser error that works only when the player is trying to listen to something. The problem is that, since the command wasn’t successfully parsed, you can’t use anything like “the current action” because the command didn’t get turned into an action.

Fortunately zarf told me how to find the half-parsed action name in the I6 internals:

To decide what action name is the action-to-be: (- action_to_be -).

That lets us set the conditions properly:

Rule for printing a parser error when the latest parser error is the can't see any such thing error and the action-to-be is the listening to action: say "You can't hear any such thing."

(That is, it lets us set the conditions properly after a bunch of trial and error to figure out what the action-name actually is; I was trying “the listening action” for a while but that’s not the action name. I had to use “showme the action-to-be” in my code to figure out what to write.)

The name of the action should be the same as listed in the index.

True! I was testing it in Playfic, though, so I didn’t have an index.

(By the way, does anyone know how to insert tab stops when you’re using Playfic?)

Nice! I’ll give this a try when I get home. Many thanks!

It works perfectly. Thanks for doing the leg work!

Out of interest, why do you suppose this isn’t handled automatically? There’s probably an obvious answer, and it might be one I need to consider. Is there a situation where the modified response would read badly?

I suppose if you had a bunch of seashells in one room and you typed “Listen to the seashell” in another room “You can’t see any such thing” would make more sense.

I don’t know if the thought behind this is any more profound than “didn’t want to put some fancy machinery in to handle an edge case” (especially because “listen” usually gets used with no object). For some commentary on the “You can’t see any such thing” message you can look at the section of Aaron Reed’s “Neutral Library Messages” that handles it. Though his alternative messages still use “see.”

That, and your first point as well. “Listen to phone” or “listen to Steve” or “listen to seashell” lead naturally towards the current default response.

The alternate “You can’t hear…” only comes up when the given noun is a sound: “Listen to music”, “listen to wind”. It’s a toss-up whether the player has typed something like that. Some games would provoke such a command, by having “music” described somewhere, but more often not, I think.

(One might try to adjust the error message to say “see” for visible objects and “hear” for sounds. But this is difficult, because there is no object to check – remember that the player’s noun phrase failed to match any object in scope!)

Not to mention if the player tries to listen to something that isn’t in the game’s vocabulary at all. Then it’s pretty much impossible to decide which message should be shown.

You could say “You can’t hear it.” which would apply equally well to tangible and intangible objects, but doesn’t indicate that it couldn’t actually parse the command.

Maybe the best solution is more testing and more synonyms :stuck_out_tongue:

It’s also sometimes appropriate to add some proxy objects for silence.

For example, if you’re in a room with music playing, you’d want a scenery object called “music” (and “sound”, etc) so that the player can listen to it. But then, if the music fades away, you might want to replace it with a different scenery object called “music” (and “sound”, but also “silence”) so that “listen to music” produces the response “You can no longer hear any music.”

This doesn’t always make sense, but it’s worth thinking about.