Compound inventory (room description) details

Same plugging in code as my earlier post (Dealing with reflexive verbs in text).

I want to add inventory details depending on whether a thing is plugged in or not. I’ve tried two ways:

Rule for printing inventory details of a thing:
	if something (called the socket) accepts the item described and something (called the plug) is plugged into the item described:
		say " (plugged into [the socket], with [the plug] plugged into it)";
	otherwise if something (called the socket) accepts the item described:
		say " (plugged into [the socket])";
	otherwise if something (called the plug) is plugged into the item described:
		say " (with [the plug] plugged into it)";

After printing the name of a thing while taking inventory or printing the locale description:
	if something (called the socket) accepts the item described and something (called the plug) is plugged into the item described:
		say " (plugged into [the socket], with [the plug] plugged into it)";
	otherwise if something (called the socket) accepts the item described:
		say " (plugged into [the socket])";
	otherwise if something (called the plug) is plugged into the item described:
		say " (with [the plug] plugged into it)";

The former obliterates any other inventory details (such as providing light), so I tried the latter. That of course suffers from infinite regression.

How do people solve the problem of adding to inventory details without erasing the standard ones entirely?

For this, you are dealing with the code in WriteAfterEntry(), which is never very fun. It is not written in a manner that makes for easy extensibility.

However, you can make use of the printing inventory desription details and printing room description details activities to do a wholesale replacement of the basics in a way that makes extensibility much easier:

The item being described is an object that varies. The item being described variable translates into I6 as "parameter_object".

Description notes is a thing based rulebook. The description notes rulebook has a list of texts called descriptive notes.

Description notes for a closed container:
	add "closed" to descriptive notes.

Description notes for a locked container:
	add "locked" to descriptive notes.

Description notes for an open openable container:
	add "open" to descriptive notes.

Description notes for an open container containing no visible thing:
	add "empty" to descriptive notes.

Description notes for a lit thing:
	unless the printing room description details activity is going on and the location is lighted:
		add "providing light" to descriptive notes.

Description notes for a worn thing:
	add "worn" to descriptive notes.

Last description notes:
	if descriptive notes is not empty:
		say " ([descriptive notes])".

For printing room description details of something (called item):
	follow the description notes rules for item.

For printing inventory details of something (called item):
	follow the description notes rules for item.

I’m not sure that it replicates all of the niceties of the built-in system, but it might not be too hard to close any observed gaps.

You would add your own descriptive text with additional rules in the rulebook, like so:

Description notes for a wacky thing:
	add "wacky" to descriptive notes.

You would have to provide a property or definition for wacky first, of course.

EDIT: Anybody wanting to use this to try to fully emulate existing code should see this post by Zed which lists many ways that inventory and room description detais differ by default.

3 Likes

This is lovely. Thanks!

No problem… though today I found out that the above is almost identical to the property-aggregation rules shown in RB Ex 425 Oyster Wide Shut, which makes me wonder why something like it hasn’t already been used to replace the legacy I6 library code.

(Some day I’ll really have to read the whole Recipe Book.)

1 Like