Advice on multiple parts of things

I have a military uniform that carries (among other things) a thing called lieutenant bars. Left lt_bar and right lt_bar are parts of lieutenant bars. However, during battle, the player may lose one or both of the bars, so I need a way to refer to lieutenant bars when both are on the uniform, and either the left or right bar when one is lost. I haven’t found the right phrasing to do so when I am examining the uniform.

The military uniform carries a jaunty hat, unbuffed shoes, and lieutenant bars.
The left lt_bar and right lt_bar are parts of lieutenant bars.

Instead of examining military uniform:
	say "Your uniform is wrinkled where it shouldn't be, but is adequate."; 
	if military uniform is carrying gash: 
		say "Four ragged tears cross your heart where you prefer medals were pinned.";	
    otherwise:
        say "There is a blank area of the shirt over your heart that is obviously bereft of medals.";
    say "Still, you are proud of your uniform, with its [list of things which are carried by military uniform].";
	if military uniform is not carrying right lt_bar:
		say "Even if you no longer have your left lieutenant bar.";
	if military uniform is not carrying left lt_bar:
		say "Even if you no longer have your right lieutenant bar.";

Whenever player examines the uniform, it gets lieutenant bars regardless of how many he has. It seems there might be an easy way to list the part of lieutenant bars (kinda like the opposite of “omit contents from listing” but I don’t know what it is. What is the best approach?

Is there a reason you’ve created the right and left lieutenant bars as sub-parts of the “lieutenant bars” object, rather than directly being parts of the uniform? I think the issue you’re running into is that you’ve got this additional abstract part, and while there are probably workarounds that can help, the simplest solution is probably just to eliminate the middleman.

I wanted for convenience to give a description of the uniform as having “lieutenant bars”, which is most of the time. I wanted to use individual bars when they are ripped off during battle. Without “lieutenant bars” in the description, the uniform is given as left lieutenant bar and right lieutenant bar, which is kind of klunky.

I even tried something like “if left lt_bar and right lt_bar were carried by uniform, then printed name was lieutenant bars.” (Yes, I know this phrasing is wrong but I couldn’t think what might work along this vein.)

Maybe try just writing a rule for grouping the two bars together, then?

https://ganelson.github.io/inform-website/book/WI_18_14.html

Pretty much nothing is built-in regarding output involving incorporation.

You might be interested in the implementation of the gloves in The Left Hand of Autumn.

An alternative to incorporation is to use properties, for example:

Lieutenant bars can be left_barred.  Lieutenant bars are usually left_barred.

etc.

Or numbers if the order of the bars is unimportant:

Lieutenant bars have a number called the bar_count.  The bar_count of lieutenant bars is usually 2.

OK, first a few basics.

Carrying is something that only people can do. If you write that The military uniform carries a jaunty hat then Inform will deduce from this assertion that the military uniform is a person. If you compile your project then click on the Index tab and then World, you will see that the military uniform has been created as a person- which I assume is not what you want.

Carrying also implies something that a person directly holds in their possession- not inside, on or part of another thing that they are carrying. So the reason your if military uniform is not carrying right lt_bar condition doesn’t work as you are expecting is that the right lt_bar and the left lt_bar are never carried by the uniform. They are instead incorporated by the lieutenant bars (until they are lost).

I assume that the player is wearing the uniform? In which case, you should decide whether all the components of the uniform (such as the hat and shoes) are really parts of the uniform as a whole, or separate things individually worn by the player.

Perhaps:

"Uniform Difficulties" by PB

Barracks is a room.

The player wears a military uniform. The jaunty hat, the unbuffed shoes, and the lieutenant bars are parts of the military uniform. The left lieutenant bar and the right lieutenant bar are parts of the lieutenant bars.

The gash is a scenery thing.

Instead of examining military uniform:
	say "Your uniform is wrinkled where it shouldn't be, but is adequate."; 
	if military uniform incorporates gash: 
		say "Four ragged tears cross your heart where you prefer medals were pinned.";	
	otherwise:
		say "There is a blank area of the shirt over your heart that is obviously bereft of medals.";
	say "Still, you are proud of your uniform[unless the list of not scenery things incorporated by military uniform is empty], with its [list of not scenery things incorporated by military uniform][end if].";
	if military uniform does not incorporate lieutenant bars:
		say "Even if you no longer have your lieutenant bars.";
	else if lieutenant bars do not incorporate left lieutenant bar:
		say "Even if you no longer have your left lieutenant bar.";
	else if lieutenant bars do not incorporate right lieutenant bar:
		say "Even if you no longer have your right lieutenant bar.";
		
Desporting is an action applying to one thing. Understand "desport [something]" as desporting.
Check desporting:
	if the noun is the military uniform or the component parts core of the noun is not the military uniform:
		say "You can only desport things which are directly or indirectly part of the military uniform." instead.
Carry out desporting:
	move the noun to the player;
	if the lieutenant bars incorporate nothing:
		now the lieutenant bars are nowhere. [ensures they are no longer listed as part of the uniform when both have been removed]
Report desporting:
	say "[We] remove [the noun].";
	try taking inventory.
	
Reinvesting is an action applying to one carried thing. Understand "restore [something preferably held]" as reinvesting.
Check reinvesting:
	if the noun is the military uniform or the component parts core of the noun is the military uniform or the player is not wearing the military uniform:
		say "You can only restore things which  you are no longer wearing as part of the military uniform." instead.		
Carry out reinvesting:
	now the noun is part of the military uniform;
	if the noun is the left lieutenant bar or the noun is the right lieutenant bar:
		now the lieutenant bars are part of the military uniform; [in case they are offstage]
		now the noun is part of the lieutenant bars.
Report reinvesting:
	say "[We] proudly restore [the noun] to its rightful place.";

	
Defiling is an action applying to one thing. Understand "defile [something]" as defiling.
Check defiling:
	if the noun is not the military uniform:
		say "You can only defile the military uniform." instead.
Check defiling:
	if the military uniform incorporates the gash:
		say "You have already defiled your uniform." instead.
Carry out defiling:
	now the gash is part of the uniform.
Report defiling:
	say "[We] tear the breast of your uniform.".

test me with "x uniform/defile uniform/x uniform/restore hat/desport hat/desport shoes/desport left/x uniform/desport right/drop all/x uniform/restore left/restore right/x uniform"
1 Like

Thank for putting in so much time to study and solve my problem. I am currently integrating it into my story. One question about your code: What does 'component parts of the core of the noun" mean? I have not seen that phrase before. Core?

Check desporting:
	if the noun is the military uniform or the component parts core of the noun is not the military uniform:
		say "You can only desport things which are directly or indirectly part of the military uniform." instead.

Ironically, I started out using component parts of the uniform and could not get that to work right. I am trying your approach now.

‘The component parts core of <something>’ is a useful undocumented phrase defined and used in the Standard Rules to mean ‘whatever thing <something> is ultimately a part of, even if through more than one level of incorporation’.

In this instance, for example, the left lieutenant bar might be a part of the lieutenant bars which are a part of the military uniform, in which case the component parts core of the left lieutenant bar is the military uniform.

More information here (scroll toward the bottom of the post to find it).