[I7] Listening to things in darkness

I’m probably being dense here, but let’s say I have this situation:

[code]The cellar is a dark room.

Every turn when the player is in the cellar:
say “There’s a faint whimper coming from one corner.”

The whimper is in the cellar. Understand “corner” and “sound” as whimper.

Instead of listening to the whimper:
say “That must be where Fido has been hiding!”[/code]

Where the result is:

As if listening required line of sight! I can think of a few laborious ways of getting this to behave, but what’s the most straightforward?

This is probably the most straightforward way.

[code]“Test”

After deciding the scope of the player:
if the player is in the dark cellar, place the whimper in scope.

The cellar is a dark room.

Every turn when the player is in the cellar:
say “There’s a faint whimper coming from one corner.”.

The whimper is in the cellar. Understand “corner” and “sound” as whimper.

Instead of listening to the whimper:
say “That must be where Fido has been hiding!”.

Test me with “l / listen to whimper”.[/code]

It’s pretty much all scopy stuff. You can see something similar here.

Hope this helps.

Aye, I thought a scope rule would be the key. As it stands, the code you’ve given me is way too broad as it would allow me to take the whimper! However, this line fixes matters:

Instead of doing anything other than listening when the noun is the whimper: say "You can only listen to the whimper."

You’ll want “or the second noun is the whimper” too, or you’ll get the wrong error messages when you try to put things in the whimper.

Ah, good shout. I’d forgotten about that!

Or you use this

To decide whether any/either/a noun is (item - a thing) (this is the match either noun rule): if item is the noun, decide yes; if item is the second noun, decide yes; decide no.

to write

Instead of doing anything other than listening when either noun is the whimper: say "You can only listen to the whimper."

which feels more I7 somehow.

No need for that:

Instead of doing anything other than listening when the current action involves the whimper: say "You can only listen to the whimper."

See 12.20

True. It works, but I never liked it as a solution. When the common solution for matching noun or second noun to a given item is to use objects that vary, then logically matching both at the same time should use the same syntax, not a completely different one using a completely different mechanism. IMHO, of course.

So I guess what I’m trying to say is, it feels wrong on a conceptual level as opposed to a functional one.

I don’t understand why you think that. It’s really almost equivalent to your phrase, except that it also checks the actor. (Actually it also uses block values so it might be considerably slower… I don’t think the current action variable is normally set so this will add extra processing.)

Also, To…: are phrases, not rules. So you should say

To decide whether any/either/a noun is (item - a thing) (this is the match either noun phrase):

A caveat: I’m obviously not at your level when it comes to programming. That said, my reasoning was this:

  • To see if X is the noun, we use a “to decide” phrase on an object that varies.
  • To see if X is the second noun, we use a “to decide” phrase on another object that varies.
  • To see if X is either of them noun, we use a “to decide” phrase on a stored action.

Conceptually, the third seems a different way of doing it for no apparent reason.

I didn’t even know that was accepted syntax. Huh.

The only reason is the evolution of the Inform library over time. The noun and second noun variables are early features (whose history stretches back to Inform 6 and 5). The current action is a recent feature that encompasses them in a more structured way.

It is possible that a future release of I7 will deprecate noun/second, or recast them to be accessors into the current action. However, there’s no urgency on that – it’s just, as you describe, a small conceptual cleanup.