I'm trying to write a rule to show what an NPC holds and it isn't quite working right

As I continue my attempt to actually make a playable IF (for once), I’ve noticed that if you examine an NPC, it doesn’t show what they hold and I would like it to.

I wrote the following rule to make that happen:

After examining someone when someone wears something or someone carries something:
	say "[if someone wears something][noun] is wearing [a list of things worn by noun].[end if][if someone carries something][noun] is holding [a list of things carried by noun][end if]."

I actually asked about something similar several years ago for another project and it worked at the time, as it does now. But I don’t like the output. So, let’s take three example NPCs.

City Guard Joseph is a man in Ephyra City Walls. He is wearing Ephyra chainmail. "A human City Guard stands here on the right side of the city entrance, keenly looking for any threats." The description is "He is wearing the uniform of the Ephyra city guard."
City Guard Zatt is a man in Ephyra City Walls. He is wearing Ephyra chainmail. He is holding a scimitar. "A dwarven city guard stands on the left side of of the city entrance, looking around for any trouble. He stands ready to defend the city." The description is "He is wearing the uniform of the Ephyra city guard."
David is a man in Ephyra City Walls. "A random traveller stands here." The description is "This man is just standing around, not doing much."

If I examine Zatt, the output is exactly what I want:

>x Zatt
He is wearing the uniform of the Ephyra city guard.

City Guard Zatt is wearing an Ephyra chainmail. 
City Guard Zatt is holding a scimitar.

If I examine Joseph, I get this:

>x Joseph
He is wearing the uniform of the Ephyra city guard.

City Guard Joseph is wearing an Ephyra chainmail. 
City Guard Joseph is holding nothing.

I don’t need the “nothing” specifically mentioned. I figured an “if” would stop that since he doesn’t hold anything, that part of the say command would never fire. But it does.

Finally, if we examine David:

>x David
This man is just standing around, not doing much.

David is wearing nothing.
David is holding nothing.

I wouldn’t want the rule to fire at all because he wears and holds nothing. I would just want it to give his description. It seems like the rule shouldn’t fire at all since David neither holds or wears anything, but it does.

I know this is a dumb piddly thing, but I’d like to get it fixed. Any ideas what I’m doing wrong?

“Someone” means “any person at all”, so “when someone wears something” means “when anyone in the world is clothed”. That’s probably not what you want.

If you want to check the specific person you’re examining, that’s “the noun”.

3 Likes

Okay, got it. You think I would have known that since I was using noun in the rule itself. But I apparently didn’t.