Seeing what a character is wearing

I’ve been messing around with Inform on and off for years. I’ve always focused on object driven puzzles before and have never actually had a character of any sort in anything I’ve made. I decided to change that today. So, I’m trying to create a puzzle that involves seeing whether or not a character is wearing a control band, but there’s a problem. I can’t get what they’re wearing to show up. For instance, I have a character declared as such:

Jill is a woman in the living room. "Jill is looking around contentedly." 
Jill wears a control band.
Rule for deciding the concealed possessions of Jill: No

It seems like the Rule should make everything she’s wearing be visible, but alas not. If I examine Jill, all I get is a message saying “You see nothing special about Jill.”

So, what am I missing here? Since what the character is wearing will change, I can’t just add it to the description. It needs to be dynamic.

The “concealed possessions” thing normally determines whether the player can refer to the possessions, but unconcealed possessions won’t by default show in descriptions (or room descriptions) unless there’s a rule for them. For instance, the “examine containers” and “examine supporters” rules in the Standard Rules are what gives you a list of what’s on supporters/in containers when you examine them.

Note that you can do “x control band” in your code–that’s because Jill’s possessions aren’t concealed so they’re accessible, even if they don’t show up in the description.

So in this case, the thing to do would be to write a rule to list the things Jill is wearing:

    Living room is a room.

Jill is a woman in the living room. "Jill is looking around contentedly." 
Jill wears a control band.

After examining Jill when Jill wears something (this is the describe what Jill is wearing rule): say "Jill is wearing [a list of things worn by Jill]."

(You need to check “when Jill wears something” so it doesn’t print “Jill is wearing nothing,” I assume. And also you would want to give Jill a non-default description, or make it an Instead rule if you want this to be the entire description.)

Also note that you don’t need to specify that the possessions are unconcealed–possessions are unconcealed by default.

(Also good to see you back!)

Just to add onto that, you’ll want to put “continue the action” at the end of that “After” rule. (You want to “continue” in “After” rules in general.)

Oh nice. That makes total sense. I continue to be impressed by Inform. Thanks!

I was wondering if I can ask one more question? I’ve successfully implemented arms to wear the control band on and Jill stops you from removing her control band. However, I’d like to make it so you have to give her an item to remove the control band. Let’s say you have to give her an override chip.

I can’t figure out how to do this. Is there a condition like “If Jill has a control chip in her inventory”? I can’t find anything like that. Eventually, my goal is to have a variable that has to have a certain value to let the control band be removed, but I figure this is a good stand-in just to get the base system working.

The definition of Jill is the same as before. The new code looks about like this:

arms are a kind of thing. arms are a part of every person.
a control band is a kind of thing. it is usually wearable.
Jill's band is a kind of control band.
A override chip is a kind of thing.

Jill is a woman in the living room. "Jill is looking around contentedly." 
Jill wears Jill's control band.

instead of taking a control band when Jill is wearing Jill's control band:
    say "I can't let you take that!"

So far, so good. I think the definition of arms is superfluous, though, and I probably don’t need it. But this make me wonder, how would you define the control band to be worn on arms, as opposed to some other part? I’m not even sure I’ll need that, I’m just curious how it’d be done.

Back to my main question: How would I check if Jill has been given a control chip? I assume I can use an if-then statement of some sort to either move the band to the player’s inventory or go on with Jill saying it can’t be removed.

Progress on this is going well when you consider I barely remember inform’s syntax. I have other rooms setup with the override chip, etc. in them so we can just assume the player has an item called control chip in his inventory for the sake of this example.

Of course you can keep asking questions! As tove said way back when, the whole coding part of the forum runs on people asking questions whenever they have them.

The main question is pretty straightforward! If you want to check if Jill has something in her inventory, you just use “has,” like “if Jill has an override chip:”. “Has” means that a person carries or wears it–see §13.4 of the documentation.

So you could write:

instead of taking Jill's control band when Jill is wearing Jill's control band:
	if Jill has an override chip:
		say "Jill placidly allows you to slide the control band off her arm.";
		now the player has Jill's control band;
	otherwise:
		say "Jill says, 'I can't let you take that!'"

Note that I changed the check to “Jill’s control band” specifically–otherwise that code will prevent you from taking any control band while Jill wears hers. Also I included a special clause to handle successfully taking the band, because the “can’t take people’s possessions rule” would block taking the band even if this rule didn’t.

(You’ll also need a rule to allow the player to give Jill the chip, since the “block giving rule” ordinarily causes people to refuse anything you try to give them!)

If you want that to apply to any control band Jill might be wearing, you could do something like this:

Instead of taking a control band (called the bracelet) when Jill wears the bracelet:
if Jill has an override chip:
	say "Jill placidly allows you to slide [the bracelet] off her arm.";
	now the player has the bracelet;
otherwise:
	say "Jill says, 'I can't let you take that!'"

Another thing is to be careful about when you’re defining things and kinds. In your code you’ve got “A control band is a kind of thing,” which is fine, and then “Jill’s band is a kind of control band,” which defines a special kind of control band called “Jill’s band” but doesn’t create any instances of it. Then when you say “Jill wears Jill’s control band” this creates a separate thing called “Jill’s control band,” which Inform doesn’t even realize is supposed to be one of those kinds! Probably you only need one of those kinds, and you might want to say
Jill wears a control band called Jill's control band.
or something like that.

So with arms and wearing things on them, I suspect that your instinct is correct that you don’t need this. It introduces a lot of complexity that doesn’t seem like it’s part of the game. It might be reasonable to have “arms” or “arm” be implemented as something the player can refer to, but unless you’ve got a very good reason for it there’s probably not anything to be gained by delving into what’s worn on what part of the body.

One possible way to do it would be:

Understand "arms" or "arm" as a person.

So “x arms” would get you the description of Jill. Or if you have arms as a separate kind of thing you could try:

Instead of examining arms: try examining a random person that incorporates the noun.

which would redirect the examining action, which might be enough. (You have to say “a random person that incorporates the noun” because Inform doesn’t know that there’s one and only one person incorporating any given pair of arms.) This should allow you to refer to “Jill’s arms,” because the arms get automatically named “Jill’s arms,” but I’m getting super weird results where if I type “x jill’s arms” it fails but if I type “x jill’s” it gives me a disambiguation result. I don’t know what’s up with that. Anyway, it’s almost certainly best not to get into details with the arms.

(If you do want to look into wearing things on things, you can look at the “What Not To Wear” example in the documentation, and Shadow Wolf’s Layered Garments extension if you want to get super elaborate. Which you probably don’t!

The weirdness I was getting about “Jill’s arms” appears to be general to things with apostrophes in their names.

Thanks again! That’s very interesting. As it turns out, since it’s been a few years since I messed with inform, I’ve forgotten most of it. But thanks for helping me out. I don’t have time to work on Inform tonight, but should tomorrow. I’m sure I’ll have more question then.

My problem is when programming (I also know C) I tend to like to make things complex for the sake of being complex. It’s a habit I’m trying to get rid of but sometimes it comes out, which is why Jill has arms now.

For my planned idea, Jill is actually supposed to be an Android. Eventually, you have to take her shirt off to get to a panel on her back. I was originally going to implement a back and stomach, etc. I guess I don’t need it.

So, let me ask a pre-emptive question I’m sure I’ll have tomorrow.

a shirt is a thing. a shirt is usually wearable.
a t-shirt is a kind of shirt.
Jill is wearing a t-shirt called colorful shirt.

If I define a shirt that way, do i need both those lines? Would it be better to just say something like:

a t-shirt is a kind of thing. a t-shirt is usually wearable.
Jill is wearing a t-shirt called colorful shirt

I think they effectively both do the exact same thing, but I sort of feel like the first might be better because there’s going to be multiple kinds of shirts in the game. If i want to change something about a shirt, I’d just need to change the definition of shirt and then all the shirts in the game would change along with it.

Though if I’m hiding a slot on her back (maybe a slot to stick the control chip), I guess I could control that by saying:

instead of examining Jill:
  If Jill is wearing a t-shirt then say, "You see Jill wearing [noun??]" 
  If Jill is not wearing a t-shirt then say, "You can see something on Jill's back."

This is all off the top of my head. That [noun??] should be the name of her shirt, but I’m not sure what to put there to make it say the name of the shirt Jill is wearing. I’m also not sure than if-then structure is correct. But the problem I see if doing it that way makes it so you can only see the status of her shirt, which also isn’t good.

I’m very tired now, but I hope you get an idea of what i’m trying to figure out.

Kinds are very powerful, especially if you need to make a lot of things that behave the same way in classes and to cut down writing synonyms:

Test Room is a room.

clothing is a kind of thing. Clothing is wearable. 
Understand "clothing/clothes/garment/garments" as clothing.

a shirt is a kind of clothing. Understand "shirt/blouse/top" as a shirt.

trousers are a kind of clothing. Understand "pants/trousers" as trousers. The indefinite article of trousers is "a pair of".

a t-shirt is a kind of shirt. Understand "t-shirt/tee/tee-shirt/teeshirt" and "tee shirt" as a t-shirt.

Jill is a woman in test room. 

a colorful shirt is a t-shirt worn by Jill. The description is "It's a plain t-shirt. You think Jill may have tye-dyed it herself." Understand "tye-dyed/tye-dye/tye/dyed" as colorful shirt. 

some khakis are trousers worn by Jill. 

After examining something (called P):
	if P wears clothing:
		say "[P] wears [a list of things worn by P]." 

> x jill

You see nothing special about Jill.

Jill wears a colorful shirt and a pair of khakis.

> x shirt

It’s a plain t-shirt. You think Jill may have tye-dyed it herself.

> x clothing

Which do you mean, the colorful shirt or the khakis?

> pants

You see nothing special about the khakis.

Similarly:

The description of Jill is "It's your co-worker, Jill[if Jill does not wear a shirt], who apparently is some sort of android since she seems to have an access panel in her back..[end if]."

An access panel is a kind of container. Understand "access/panel" as an access panel. 
A back access panel is a kind of access panel. Understand "back" as a back access panel.
Jill's access panel is a back access panel. It is part of Jill.

Before doing something to an access panel (called AP):
	if AP is incorporated by a person (called P):
		if P wears a shirt:
			say "You wouldn't know if [P] has an access panel.";
			stop the action.
			
[for testing]
Instead of jumping:
	try Jill taking off a random shirt worn by Jill. 

> x jill

It’s your co-worker, Jill.

Jill wears a colorful shirt and a pair of khakis.

> x clothing

Which do you mean, the colorful shirt or the khakis?

> shirt

It’s a plain t-shirt. You think Jill may have tye-dyed it herself.

> x back

You wouldn’t know if Jill has an access panel.

> jump

Jill takes off the colorful shirt.

> x jill

It’s your co-worker, Jill, who apparently is some sort of android since she seems to have an access panel in her back…

Jill wears a pair of khakis.

> x jill’s back

Jill’s access panel is empty.

Good stuff from Hanon there. Note that the “(called foo)” trick solves the question you asked about referring to the shirt in your syntax; you can use that in rule headings or on ifs in the middle of the rule and it will assign that thing to a temporary variable. (If there is more than one matching thing it defines the thing that’s first internally somehow–so this is best used when there’s guaranteed to be only one, or you don’t care what it picks and that it’s likely to pick the same one every time.)

The other thing you said about how your rule means you’re only examining the shirt can be taken care of by changing “Instead” to “After” or “Report”–the description gets printed by a “Carry out examining” rule and these rules run after the carry out rulebooks. (“After” rules cut off action processing unless you have “continue the action,” as Draconis said–that might make a difference if you have other relevant “after” and “report” rules.)

Report examining Jill:
	if Jill is wearing a shirt (called garment):
		say "You see Jill wearing [a garment].";
	otherwise:
		say "You can see something on Jill's back."

Other notes:
you don’t need “then” in these statements, and it’s probably easier if you use tabs to indent them.
The rule should probably apply to any shirt if there’s more than one kind!
I made it “[a noun]” because it seemed like you’d want “a tie-dye T-shirt”; you could change it to “the” if that’s what you want.
Also remember the end-of-line punctuation!

That’s some really good stuff. I like it. As for end of line punctuation… um, yeah. I’m bad about that. I’m really bad with semicolons in C as well. I can’t count the number of times I’ve pulled my hair out trying to figure out why something won’t compile only to realize I forgot one (or more) semicolons. One of the drawbacks to learning to code in basic in the 80s, I guess.

So, I was thinking. I’m likely going to have multiple androids. Would it be better to do something like:

An access panel is a kind of container. A back access panel is a kind of access panel.
An android is a kind of person. A back panel is part of an android.
Jill is an android.
John is an android.

Now, for instance, I have two androids and don’t have to double definitions. I’m not sure if this a good idea or me being unnecessarily complex. But I think I could still call it the same, referring to it as “Jill’s back panel”?

I’m busy and haven’t had time to really do anything serious since Sunday. Hopefully soon, as I have a ton of ideas in my head.

You can say One back panel is part of every android. and it should automatically call it “Jill’s back panel”.

You can use the SHOWME command and say “showme jill” and it will list everything that’s part of her.