Rule not working

This is weird. Throughout all my testing, this rule has never failed, yet after my last snafu (the check rule involving eating cereal), this seemingly unrelated rule is failing.

if player does not wear pair of socks: say "Are you really prepared to go out like that?"; stop the action; otherwise: if player does not wear pair of shoes: say "Are you really prepared to go out like that?"; stop the action; otherwise: if player does not wear shirt: say "Are you really prepared to go out like that?"; stop the action; otherwise: if player does not wear pants: say "Are you really prepared to go out like that?"; stop the action; otherwise: if player does not wear jacket: say "Are you really prepared to go out like that?"; stop the action; otherwise: if player does not carry wallet: say "Your wallet may be empty, but I still wouldn't leave without it."; stop the action; otherwise: continue the action.

Transcript:

rules
Rules tracing now switched on. Type “rules off” to switch it off again, or “rules all” to include even rules which do not apply.

n
[Rule “declare everything initially unmentioned rule” applies.]
[Rule “standard set going variables rule” applies.]
[Rule “announce items from multiple object lists rule” applies.]
[Rule “set pronouns from items from multiple object lists rule” applies.]
[Rule “before stage rule” applies.]
[Rule “instead stage rule” applies.]
[Rule “Instead of going north while player is in Bedroom” applies.]
Are you really prepared to go out like that?

[Rule “A first turn sequence rule” applies.]
[Rule “every turn stage rule” applies.]
[Rule “Every turn” applies.]
Act now, or forever hold your peace!

[Rule “A last turn sequence rule” applies.]
[Rule “notify score changes rule” applies.]

Ummm, how is it failing? Your transcript shows the correct response for trying to go north if one of the clothing items isn’t worn. I presume this is the Instead of going north rule? (Your code block is missing the start of the rule)

Sorry about that. Here’s the first line:

Instead of going north while player is in Bedroom:

Let me note that “i” reveals that the player is wearing all five clothing items.

The last item is whether the player is carrying the wallet. Is that included in the inventory? Is the player carrying it? …no, that would produce a different error message, wouldn’t it?

I’m going to fall back on the possibility that one of the objects is not named “pants” or “socks” or whatever. That probably would produce a different error, but it should be checked.

There’s a “pair of socks” and a “pair of shoes,” but whenever I’ve typed “wear socks” and “wear shoes,” which I did in in the transcript above, it’s worked, as the inventory shows.

Inform is more flexible about understanding things when you’re playing than when you’re writing code for it. That said, you’ve used those names in the code, so It’s probably not that (although what did you call the pants?)

Could I suggest changing the rejection message so that each of the five cases is different. That’ll pinpoint where things have gone wrong.

Doh!
I shoulda thunka that!

Turns out it fails at “pants,” even though the player is wearing pants.

Transcript:

n
Are you really prepared to go out like that?pants
Get in the groove and move!

i
You are carrying:
a trophy
a wallet (with $0 in it) (closed)
a pair of pants (being worn)
a jacket (being worn)
a pair of shoes (being worn)
a pair of socks (being worn)
a shirt (being worn)

Don’t keep me waitin’.

Do you have another thing in the game with “pants” in its name? That sometimes confuses Inform. (And could be fixed by changing the internal names or by writing out “if player does not wear pair of pants.”)

No other pants. I refer to the pants as “pants” and “pair of pants,” but I also have an understand rule that pants = pair of pants.

I don’t know why this rule is failing me now, because it worked a jillion times before.

Reminder: Understand rules are ONLY for what the player types. They have nothing to do with what you can call an object in your own code. I don’t know how that could affect the current conundrum, though.

I think I do. Holmes, could you paste the code for the pants?

Yes, but it’s late. Will do so tomorrow. Thanks.

Here is all the references to “pants” in the code:

[code]Instead of looking into the mirror:
if player does not wear clothes:
say “You look kinda bony, standing there in just your underwear. What is that pattern, anyway? Little red hearts?”;
otherwise:
if player does not wear jacket:
say “You’re not fully dressed.”;
otherwise:
if player does not wear shirt:
say “You’re not fully dressed.”;
otherwise:
if player does not wear pants:
say “You’re not fully dressed.”;
otherwise:
if player does not wear socks:
say “You’re not fully dressed.”;
otherwise:
if player does not wear shoes:
say “You’re not fully dressed.”

Clothes are a kind of wearable thing. The shirt, the pants, the pair of socks, the pair of shoes and the jacket are clothes.

The pair of pants is a wearable thing. It is in Closet.

The description of the pair of pants is “They[’]re shiny black.”

Understand “pants” as the pair of pants.

Instead of going north while player is in Bedroom:
if player does not wear pair of socks:
say “Are you really prepared to go out like that?socks”;
stop the action;
otherwise:
if player does not wear pair of shoes:
say “Are you really prepared to go out like that?shoes”;
stop the action;
otherwise:
if player does not wear shirt:
say “Are you really prepared to go out like that?shirt”;
stop the action;
otherwise:
if player does not wear pants:
say “Are you really prepared to go out like that?pants”;
stop the action;
otherwise:
if player does not wear jacket:
say “Are you really prepared to go out like that?jacket”;
stop the action;
otherwise:
if player does not carry wallet:
say “Your wallet may be empty, but I still wouldn’t leave without it.”;
stop the action;
otherwise:
continue the action.[/code]

[b]That’s it.[b]

I’m guessing that this:

The shirt, the pants, the pair of socks, the pair of shoes and the jacket are clothes.

defined a thing called “the pants,” while this:

The pair of pants is a wearable thing.

defined a different thing called “pair of pants.” (And as someone said to you above, the “Understand” statement doesn’t affect the ways you can refer to things in your own source code; it only affects how things are understood in the game when the player types it.)

Check the “world” tab in the “Index” in the IDE (that’s the Inform program where you’re coding) to see if there are two different things there. This is a good thing to do if you might think you accidentally defined two objects where you only want one.

Changing “pants” to “pair of pants” in the first line will probably work. You sometimes have to be careful with initial declarations (that is, things like “The pants are wearable” that aren’t in rules) to make sure you don’t implicitly define something you don’t want.

Well, there’s the problem. You’ve defined two objects (or so it appears to me – not an Inform guru, just a darn good guesser). One is pants, the other is pair of pants. The pair of pants is in the closet, so that’s what the player puts on. The pants is nowhere. But in your Instead rule you’re checking for pants, not pair of pants.

To reiterate, Understand rules apply only to stuff the player can type, not to your own code. The compiler sees “pants”, so it thinks you’re talking about the pants object, not the pair of pants object.

Or at least, that’s my guess without having tested it.

Yeah, what they said. To fix: Tack ‘pair of’ onto all the pants in the code, that doesn’t already have one, and remove the Understand line. It’s not doing anything.

Well, toot.

I changed all references to “pair of pants” and got the same result.

Transcript:

take all
shirt: Taken.
pair of socks: Taken.
pair of shoes: Taken.
jacket: Taken.
pair of pair of pants: Taken.

One o’clock, two o’clock, three o’clock – Do somethin’, man!

wear shirt
You put on the shirt.

You want to WHAT?

wear pants
You put on the pair of pair of pants.

I’ll get you ice cream if you just MOVE!

wear socks
You put on the pair of socks.

Decisions, decisions …

wear shoes
You put on the pair of shoes.

Make like a fiddle: ske-diddle!

wear jacket
You put on the jacket.

What’s the word, bird?

w

Bedroom
Your bedroom is stark, but otherwise not elegant. That’ll change someday. You can go east to the closet, southeast to the lavatory, southwest to the kitchen, or north to Union Street.

You can see a mirror, a bed, a small stand (on which are a trophy and a clock), a bedstand (in which is a drawer (closed)) and a leather case (closed) here.

On your mark, get set …

open drawer
You open the drawer, revealing a wallet (with $0 in it).

Make my day – tell me what you’re gonna do next!

take wallet
Taken.

There’s a whole lot of movin’ goin’ on. Be a part of it.

take trophy
Taken.

What’s Plan B?

n
Are you really prepared to go out like that?pants

Did you by any chance do a global search and replace for “pants” to “pair of pants”? Because it looks like now the thing you’re wearing is “pair of pair of pants.” Again, check the World tab of the Index to see if you have one thing or two.

And I think the general rule for object creation is something like this:

The first time Inform sees something that might be an implicit declaration and that doesn’t match the name of any existing object, it tries to create it. After that, you can refer to the name in the source code by any words that are part of the name (up to a point–“of” won’t work). Again, this is in the source code, so as Unreluctance said the “understand” lines won’t affect this at all.

So if you say “The pants are clothes” it creates something called “pants.” And then if you say “The pair of pants is a wearable thing,” since “pair of pants” can’t refer to the thing called “pants” (it has extra words), it creates the pants.

But if you create “pair of pants” first then you can talk about the “pants” afterwards and Inform will understand that you’re talking about the pair of pants.

This is tricky, though. When in doubt, check the World tab of the Index and change every declaration to the full name of the object, until the problem goes away.