Not getting the expected results.

I am creating an IF in which the player search for who has their phone, keys, hat, and coat.

The is the code I have for asking a person if they have the phone.

[code]Instead of asking anyone about “phone” when the person is carrying the phone:
say “I have it!”;

Instead of asking anyone about “phone” when the person is not carrying the phone:
say “I don’t have it!”;[/code]

The problem that I am having is even when I force the phone into a certain person’s inventory, I always get “I don’t have it!” (I’m positive the person has it because I have another command that list’s the person’s inventory.)

What I don’t understand is why it’s not saying “I have it!” when the asked person has it. I know the code works, because it displays “I don’t have it!” for everyone, and I’m not getting a compile error.

Those instead rules should read:

[code]Instead of asking anyone about “phone” when the NOUN is carrying the phone:
say “I have it!”;

Instead of asking anyone about “phone” when the NOUN is not carrying the phone:
say “I don’t have it!”;[/code]
Then they will work as expected.
(The noun of the action is referred to as ‘the noun’ whether it is a person or not).

The problem is that Inform treats “the” and “a” as synonyms, so when you’re asking Inform “if the person is carrying the phone,” what it’s checking for is “if a person is carrying the phone” – that is, any person, anywhere in the game. Similarly, you’re checking, in a later rule and therefore the rule Inform consults first, whether anybody in the game isn’t carrying the phone. So Inform’s looking at all the people in the game, and as soon as it finds one that isn’t carrying the phone (such as the player), it runs the “I don’t have it!” code and calls it a day.

So what you need to do is be checking if that specific person has the phone. You do that like this:

Instead of asking someone (called the askee) about "phone": if the askee encloses the phone, say "I have it!"; else say "I don't have it!".

(By the way, I’m using “enclosed by” instead of “carries” because it also includes indirect enclosure, such as carrying the phone inside a purse.)

Thanks, it works perfectly. I’m learning so much through this forum =)

This isn’t actually what’s happening – when rules are equally specific, Inform consults the earlier one first (that is, the one that’s earlier in the source code). In this case Inform actually judges “when the person is not carrying the phone” to be more specific than “when the person is carrying the phone” and consults it first. (The index says this is due to Law III.5.2, “Actions/When/Circumstances.” That’s supposed to work by counting the clauses; perhaps “not” counts as an extra clause?)

Oh, interesting. I thought later rules overruled earlier ones, like how rules in your own source overrule rules in extensions. Thanks for the clarification!