Searching, examining and the location

Hi everyone,

I wanted to give a better response to “search” (with a missing noun) than the standard “What do you want to search?” because in my game it is likely that the player will try to search the room by merely typing “search.”

So I looked at the rule that was in play when you “search” without supplying a noun so that I could turn it off. I was expecting something like “the block vaguely searching rule” like what runs when you “go” without supplying a direction, but it was just the “After reading a command” rule.

I couldn’t think of what to do with that and searching the documentation didn’t give me any help.

So I came up with a workaround that seems to work fine. I created another action called “presearching” and used it to fix the problem I was having. But, I’m concerned that I’m opening myself up to some unforeseen bugs.

I wanted to see if this is OK, or if there’s a better way to do it. And then I have one more question. Here is my code:

Understand "search room" and "examine room" and "x room" as a mistake ("The SEARCH, EXAMINE and X commands are equivalent and will yield the same results. They can be applied to almost anything in a location, but not to the location itself.").

Before searching:
	if the noun is the location of the player:
		say "The SEARCH, EXAMINE and X commands are equivalent and will yield the same results. They can be applied to almost anything in a location, but not to the location itself.";
		stop the action;
	try examining the noun instead;
	
presearching is an action applying to one thing.
Understand "presearch [something]" and "search" and "examine" and "x" as presearching.
	
Rule for supplying a missing noun when presearching: now the noun is the location.

Before presearching:
	try searching the noun;
	stop the action;

My final question is, is there an easy way to allow the player to reference the printed name of the location? That is, if the player types, 'search [the printed name of the location of the player]" it would be nice if I could give a better response than “You can’t see any such thing,” which seems a bit silly. And it’s a natural thing for the player to do, especially when in generic-sounding locations like “Bathroom” or “Cave.” And I don’t want to have to come up with individual exceptions for every single location in the game.

1 Like

In an updated version of my IFComp game I added a backdrop so the player can refer to the “room” or “scenery” in a generic way, resulting in looking at the room.

The world is a backdrop. It is everywhere.
The printed name of the world is "scenery".
Understand "room", "scene", "scenery" as the world.

Instead of examining the world, try looking.
Instead of searching the world, try looking.

However your example makes me think of:

Then if you want to allow the player to examine the room, you can do:

After deciding the scope of the player while examining (this is the place the room in scope when applicable rule), place the location in scope, but not its contents.

Do check out the referred post, it is much more extensive than the extract I give here.

2 Likes

This is the one I use: Overly elaborate looking - #2 by otistdog

1 Like

Your original code works (and it’s always good to have working code!) However, it’s a bit overcomplicated. You’re sort of mixing up two approaches.

You could do this:

Vague-searching is an action applying to nothing.
Understand "search" and "examine" and "x" as vague-searching.

Before vague-searching:
	say "The SEARCH, EXAMINE and X commands are equivalent and will yield the same results. They can be applied to almost anything in a location, but not to the location itself.";
	stop the action;

Or you could do this:

Understand "search" and "examine" and "x" as searching.

Rule for supplying a missing noun when searching: now the noun is the location.

You don’t need to define a new action and write a “supplying a missing noun” rule. The “supplying a missing noun” rulebook really only exists for cases where you don’t define a new action.

This doesn’t answer the other half of your question; see the rest of this thread.

And I don’t want to have to come up with individual exceptions for every single location in the game.

That works though. Like I said, a solution that works is always good!

2 Likes

Thanks so much to each of you! Your advice really helped. It’s too bad that I can only mark one reply as a solution.

I’ve been using what each of you said in one way or another and it’s working great!

2 Likes

I just wanted to point out that, contrary to the mistake text in your sample code, SEARCH and EXAMINE are typically not equivalent. Though if they happen to be equivalent in your game, then that’s fine.