Hiding object from inventory list

Is there a way to hide a particular, owned object from the inventory list? In my specific case, my character is wearing a hat. I don’t want the hat to appear as an object when the player checks their inventory.

Here’s a solution I found elsewhere (with your hat added):

Instead of taking inventory:
	say "[if the player carries something]You're carrying [a list of things which are not the hat carried by the player][otherwise]You're not carrying anything";
	say "[if the player is wearing something]. You're wearing [a list of things which are not the hat worn by the player][otherwise].[end if]"

It seems to be based on an older version of Example 65 (Persephone) in the Inform Recipe Book:

"Persephone" 

Instead of taking inventory: 
    say "[if the player carries something][We]['re] carrying [a list of things carried by the player][otherwise][We]['re] empty-handed"; 
    say "[if the player wears something]. [We]['re] wearing [a list of things worn by the player][end if]." 

The Fancy Party is a room. The player carries a sword, a strawberry stem, and 20 credits worth of platinum. The player wears a sash indicating lordhood. 

Test me with "i / take off sash / i / drop all / i". 

It’s probably possible to amend the existing taking inventory action with a new rule.

Yeah, here’s a version modifying the taking inventory rule, relying on setting the hat as unmarked for listing, which maintains the standard inventory responses and formatting:

The hat is worn by the player.  The hat is unmarked for listing.   

The print standard inventory rule is not listed in any rulebook.

Carry out taking inventory (this is the new print inventory rule):
	Let L be a list of objects;
	Repeat with item running through objects enclosed by the player:
		If item is not the hat, add item to L;
	If L is empty:
		Say "[text of print empty inventory rule response (A)][line break]";
		Stop the action;
	Say "[text of print standard inventory rule response (A)]";
	List the contents of the player, with newlines, indented, including contents, giving inventory information, with extra indentation, listing marked items only;

The marked for listing property is a temporary one, which can be given or taken away from any object at any time (between rules, anyway). So you shouldn’t rely on any particular thing being persistently marked or unmarked. (And in actual fact all things start unmarked at the start of the story, so your rule as written would always display an empty inventory regardless of what the player was carrying.)

A better version of that would be:

The hat is worn by the player. 
An interocitor is carried by the player.

The print standard inventory rule is not listed in any rulebook.

Carry out taking inventory (this is the new print inventory rule):
	now all things enclosed by the player are marked for listing;
	now the hat is unmarked for listing;
	if no things enclosed by the player are marked for listing:
		say "[text of print empty inventory rule response (A)][line break]";
	otherwise:
		say "[text of print standard inventory rule response (A)]";
		list the contents of the player, with newlines, indented, including contents, giving inventory information, with extra indentation, listing marked items only.

For some more examples, see in particular Equipment List at WI11.14 – notably there’s an example there of listing worn and carried items separately, which may be more useful. (After all, why give the player a hat at all unless they’re supposed to do something with it at some point, suggesting that they may need reminding that it’s there.)

Huh, funny – I’d actually written an initial version of the rule manually marking and unmarking stuff as in your version, since I thought the property got reset each turn, or at least any time the player took inventory, handled an object, or examined it, or anything like that (the documentation on this appears pretty much nonexistent). But I got curious and tried experimenting, and in the test case of the player starting out wearing the hat but with several objects lying around in the starting room, it’s not correct that the rule always displays an empty inventory – any combination of picking up, dropping, and examining, then taking inventory that I tried gave the correct behavior.

Now that I’m trying things more carefully, turns out looking is the behavior that actually does reset things, after which things of course get chaotic. Should have just trusted my initial sense of the Inform 7 folkways, I suppose!

I think the ‘marked for listing’ property is a general-purpose workflag intended for use in all kinds of situations where a list of things is to be printed and it can therefore be set and unset at will by any rule at any time. Printing a room description as a result of looking is just one of many things that might change this property either for all things or a subset of them. It shouldn’t therefore be considered as defining a characteristic of any object and the initial state of the flag for any object when writing code should generally probably be considered as undefined.

Thank you, all. There was more to that than I was expecting!