examine object only if carried

if I examine an object and its in the room I get a message telling me about the object. however I want to examine the object only if the player is holding [carrying] it.

I’ve tried several attempts but errors every time, how is this done and why isn’t this a standard rule?

It’s not a standard rule because, historically, EXAMINE applies to furniture and NPCs as well as portable objects that you haven’t picked up yet.

You can add a custom rule:

Instead of examining when the player does not enclose the noun:
	say "You can only examine things that are in your inventory."

or “…when the player does not carry the noun” if you want to exclude clothing and things in containers.

As zarf said, this is virtually never done so it has to be designed really well or players are likely to find the restriction frustrating.

thanks that works great ;]
however I see what you mean when it comes to examining scenery.

I’m a little late to this discussion, but it occurs to me that there’s a possible middle ground to this - you could make a distinction between examining something and examining something in the inventory. It might look like this:

A thing has some text called the closeup-description. Instead of examining something when the player encloses the noun: Say the closeup-description of the noun.

The Suspicious Notebook is a thing in Speakeasy. The description is “It’s just a notebook. Nothing suspicious about it… at least from this distance.”. The closeup-description is “Mon Dieu! The notebook contains every horse race result for the next ten years!”.

test me with x notebook/take notebook/x notebook[/code]

Another option is varying the text in the description:

The description of the grain of rice is "It seems to be a normal grain of rice.[if grain of rice is carried by the player][line break]As you bring the rice closer to your eyes, you notice it has the entire Encyclopaedia Frobozzica written on it in teeeeeeeny tiny lettering![end if]"

You could also make a distinction between items you want examinable and not.

[code]A thing can be unregardable.

Check examining an unregardable thing:
if the noun is not carried:
say “Without close scrutiny, it looks like every other [noun].” instead.

a book is in the room. It is unregardable. The description is “You open the book, since you’ve wisely chosen to pick it up, and learn a new spell!”[/code]