How to listen, smell, touch the room (rather than a thing)?

I would like my player to be able to listen (to), smell, touch, and even taste my rooms. How do I get this to work?

Right now I have this code:

Instead of listening in the Plaza, say “It’s hard to pick up on anything more specific than the exuberant voices of the singers.”.
Instead of smelling in the Plaza, say “You smell incense, cigarettes, and sweat.”.
Instead of touching in the Plaza, say “You kneel and touch the dusty ground. The dirt sifts through your fingers and sticks to your sweaty palms. In some places, it has a reddish hue.”.
Instead of tasting in the Plaza, say “Sure. You go ahead and lick the Plaza. It tastes like dirt and ashes. And a little bit metallic.”.

And this works, except that the output gives a parenthetical that assumes the player is interacting with the object in their inventory e.g.:

touch
(the letter)
You kneel and touch the dusty ground, packed down over the years by thousands of pilgrims’ feet. The dirt sifts through your fingers and sticks to your sweaty palms. In some places, it has a reddish hue.

How can I get that parenthetical to go away, or how can I rewrite it to be (the Plaza)?

Alternately, I feel like there’s probably some better way to go about this than using “instead of,” which of course means that individual things in these rooms can’t be interacted with in this way.

Thanks for your help!

2 Likes

Something about how rooms work in Inform is that they are not, by default, placed in scope during play. In other words, the player cannot interact with them. The game never recognises their typed names, so the player can’t point actions at them. If you type EXAMINE PLAZA in your game, it’s going to say “I can’t see any such thing.”

Now, you’re dealing with various sense actions, which are programmed in different ways in the Standard Rules.

LISTEN requires a noun after it, and if it doesn’t get one, behind the scenes it takes the room the player’s in as its noun. I know I just said the room’s not in scope, but that’s for actions entered by the player. Code can get at it.

You can verify this by typing ACTIONS (a test command showing you what actions are running each turn), then LISTEN. You’ll see it says “(listening to plaza)”.

SMELL works the same as LISTEN, grabbing the location for a noun if it can’t get one.

Touching and tasting are too hands on for that. The default programming assumes people want to touch something specific, so these commands require a noun, and will just grab at whatever thing in the location is handy if they aren’t given one. Whatever’s handy will never include the room itself, because by default it is out of scope. In your game, I assume the letter is all that’s handy.

So your listening and smelling are working how you’d want for your purposes. Touching and tasting aren’t.

You’re right to consider whether ‘Instead of’ is the best way to do things. Newcomers to the language tend to overuse it, which can cause trouble later, but here it’s appropriate for the smelling and listening. It suppresses the default output of ‘You smell nothing unexpected’ that you need to suppress.

If you want TOUCH to default to targeting the room when nothing is supplied, in general in your game, you’ve got a bit of tweaking to do. Which I need to think about for a moment.

-Wade

3 Likes
  1. I’ve created a demo project which alters the touching and tasting actions to point to the location when no noun is supplied, and it puts the location in scope when carrying out those actions.

  2. It also puts the location in scope when the player types EXAMINE, so that the room’s description can be printed if they type X PLAZA (or wherever they are)

If you look in the Standard Rules, you can see the current definition of touching and its grammar. They say,

Touching is an action applying to one thing.

and

Understand "touch [something]" as touching.

This means typing TOUCH with no noun isn’t tolerated by Inform. It’s going to grab at a noun and shove it in there, hence the grabbing at the letter in your game. If it can’t get one, then it’s going to say ‘You must supply a noun.’

If we allow the player to type just “TOUCH”, we can add a rule that decides what noun to put in there in difference circumstances. So in my demo I’ve added this:

Understand "touch" as touching. (note the no [something])

and this:

Rule for supplying a missing noun when touching:
	now the noun is the location;

And I did the same for the identically defined tasting action.

One more thing needed to make this work is putting the location in scope at such moments, because it’s not normally there. In the following rule, I name all the actions that that I want to have put the location in scope:

After deciding the scope of the player while examining or touching or tasting (this is the place the room in scope when applicable rule):
	place the location in scope, but not its contents;[everything else should already be in scope if applicable]

Re: LISTEN, the rule is no longer ‘listening in the plaza’ (or smelling IN the plaza) because that would mean even if we listened to something else, it would give the plaza’s audio. The rule now says listening TO the plaza. This means the player can still target other things with LISTEN while in the plaza. You can change it back if you want the plaza’s sound to override any other listening in this location.

We’re getting a bit advanced here, but we’re done. Try the demo. Note the player is holding a lollipop. This is to prove that typing TOUCH on its own chooses the location and not the lollipop.

Summary
The Plaza is a room. Description of the plaza is "What a place! (replace this with actual cool description.)".

player carries a lollipop.

Understand "taste" as tasting.

Rule for supplying a missing noun when tasting:
	now the noun is the location;

Understand "touch" as touching.

Rule for supplying a missing noun when touching:
	now the noun is the location;

After deciding the scope of the player while examining or smelling or touching or tasting or listening to (this is the place the room in scope when applicable rule):
	place the location in scope, but not its contents;[everything else should already be in scope if applicable]

Does the player mean doing anything to the location:[prioritizes verbs working on things over the room itself]
	it is unlikely;


Instead of listening to the Plaza, say “It’s hard to pick up on anything more specific than the exuberant voices of the singers.”;

Instead of smelling the Plaza, say “You smell incense, cigarettes, and sweat.”;

Instead of touching the Plaza, say “You kneel and touch the dusty ground. The dirt sifts through your fingers and sticks to your sweaty palms. In some places, it has a reddish hue.”;

Instead of tasting the Plaza, say “Sure. You go ahead and lick the Plaza. It tastes like dirt and ashes. And a little bit metallic.”;

Test me with "listen/listen to me/smell/smell me/taste/touch/x plaza".

EDIT - Added more actions to the scope rule, otherwise e.g. LISTEN would succeed in listening to the location, but LISTEN (LOCATION) wouldn’t.

-Wade

4 Likes

Thank you so much!!! This is extraordinarily helpful.

1 Like