Taking of a shirt

Hi,

I’m new to Inform 7 and I have a basic question. Why doesn’t this work? :slight_smile:

Cell is a room.

A overweight man is in the cell. He is wearing a shirt. “An overweight man dangles in a rope from the ceiling[If wearing shirt] The man wears a blue shirt[otherwise] The man is bare chested.[end if]”.

This just gives me “the man is bare chested” every time.

All help is much appreciated!

Change “[if wearing shirt]” to “[if the item described is wearing the shirt]” or “[if the overweight man is wearing the shirt]”.

I can’t really answer your question of why this isn’t working, because I’m not sure how “if wearing shirt” is being interpreted, but spelling it out a bit more seems to work.

Thought I tried that but I guess not because it worked :slight_smile: Thanks!

Actually what I did is I used only man and not overweight man. That was the difference

Yup, “man” is predefined as a kind of person, so if you had “[if the man is wearing a shirt]” it would get evaluated as true if any man was wearing a shirt (the word “the” gets treated as “a” in situations like that); but the overweight man isn’t actually defined as a man, so the test doesn’t pick that up. (And you don’t want it to come out true if the player is wearing a shirt, for instance.)

If you had called him “the overweight dude” and then written “if the dude is wearing a shirt” it would’ve worked; it’s only because “man” is already defined that the compiler doesn’t understand “man” as referring to the overweight man.

That makes sense, Thanks!

New problem: when I type “take off shirt” it gives me: (must take the shirt first)
“It probably belongs to the overweight man.”

I changed the code to:
Before taking the shirt:
Say “You tear the man’s shirt off”;
Now the player is carrying the shirt.

But this gives me:

(must take the shirt first)
You tear the man’s shirt off.

You’re not wearing it.

How do I fix this? :slight_smile:

The reason for the original problem is that “take off the shirt” by default translates to the action where you take off something that you’re wearing yourself. This taking off action is defined so it only works on something you’re holding, so if you try it on something you aren’t holding it executes what’s called an “implicit take” – that’s what prints "(first taking the shirt) and what triggers your “before taking the shirt” rule. But when the implicit take is done with, the taking off action still runs – that’s what prints the “You’re not wearing it” message.

You can fix this by redirecting the taking off action completely:

Before taking off the shirt: try taking the shirt instead.

The “instead” means that after this rule runs, the “taking off” action stops completely. (For more detail, read the documentation on rulebooks, though the documentation can be a heavy lift.) So you just, well, try taking the shirt instead.

But you don’t actually want these rules to run whenever the player tries to take/take off the shirt; they only make sense if the overweight man is wearing the shirt. So:

[code]Instead of taking the shirt when the overweight man wears the shirt:
Say “You tear the man’s shirt off.”;
Now the player is carrying the shirt.

Before taking off the shirt when the overweight man wears the shirt:
try taking the shirt instead.[/code]

(I changed the “before taking the shirt” rule to an “instead of taking the shirt” rule because that’s a little more flexible – it lets you use other Before rules – and “instead” rules automatically stop the action unless you tell them not to, so you don’t have to worry about extra messages from the taking action. But the “Before taking off the shirt” rule seems like it has to be a “before” rule so it can get in before the rules that generate implicit takes.)