Grouping initial appearances in 1 paragraph

Ideally, I would like to group the initial appearances of objects in a given room into a single paragraph rather than having one paragraph generated per initial appearance, as is the default behaviour.

If possible, I would like to adhere to the following constraints: no Inform 6 syntax, no extensions that go beyond this basic requirement, and no significant alterations to the standard rules.

I realise this is a lot to ask, but my priority is to use code that I understand, can modify and maintain. Any help would be appreciated, even if it means explaining that I have no choice but to bend these constraints and/or make an effort to familiarise myself with them.

As in, you want all initial appearances, in general, to be printed in a single paragraph per room?

Yes, if possible.

So, this is the rule in the Standard Rules that prints initial appearances.

For printing a locale paragraph about a thing (called the item)
    (this is the use initial appearance in room descriptions rule):
    if the item is not mentioned:
        if the item provides the property initial appearance and the
            item is not handled and the initial appearance of the item is
            not "":
            increase the locale paragraph count by 1;
            say "[initial appearance of the item]";
            say "[paragraph break]";
            if a locale-supportable thing is on the item:
                repeat with possibility running through things on the item:
                    now the possibility is marked for listing;
                    if the possibility is mentioned:
                        now the possibility is not marked for listing;
                say "On [the item] " (A);
                list the contents of the item, as a sentence, including contents,
                    giving brief inventory information, tersely, not listing
                    concealed items, prefacing with is/are, listing marked items only;
                say ".[paragraph break]";
            now the item is mentioned;
    continue the activity.

The easiest way to remove the paragraph breaks is to literally just remove the two instances of [paragraph break] from this code. Does that count as a significant alteration?

(Or rather, making a copy of this rule, removing the [paragraph break]s from it, and inserting it in place of the original rule. Don’t edit the Standard Rules file directly.)

1 Like

Yes, thank you for this approach, which fully meets my unreasonable assumptions. Since simply removing paragraph breaks is too radical, especially with regard to the last element, I have adapted your proposal as follows:

A room has a number called expected initial appearances.

Before looking (this is the Before looking - Expected initial appearances counting rule):
	now the expected initial appearances of the location is 0;
	repeat with item running through things in the location:
		if (the item provides the property initial appearance) and (the item is not handled) and (the initial appearance of the item is not ""):
			increase the expected initial appearances of the location by 1.
	
For printing a locale paragraph about a thing (called the item) (this is the grouped initial appearance in room descriptions rule):
	if (the item is not mentioned):
		if (the item provides the property initial appearance) and (the item is not handled) and (the initial appearance of the item is not ""):
			increase the locale paragraph count by 1;
			say "[initial appearance of the item]";
			[say "[paragraph break]";]
			if (a locale-supportable thing is on the item):
				repeat with possibility running through things on the item:
					now the possibility is marked for listing;
					if (the possibility is mentioned):
						now the possibility is not marked for listing;
				say "On [the item] " (A);
				list the contents of the item, as a sentence, including contents,	giving brief inventory information, tersely, not listing concealed items, prefacing with is/are, listing marked items only;
			[say ".[paragraph break]";]
			now the item is mentioned;
			if (the locale paragraph count is the expected initial appearances of the location):
				say "[paragraph break]";
	continue the activity.
	
The grouped initial appearance in room descriptions rule is listed instead of the use initial appearance in room descriptions rule in the for printing a locale paragraph about rules.

The only remaining imperfection is the automatic insertion of a line break between elements:

Carpeted Hallway
A wide, straight corridor with felted walls stretching as far as the eye can see. 

The ship's deck plans are regularly displayed on the walls. 
This compartment has a few elevators spaced evenly apart for passengers (Type "Go inside", "Inside" or "In" if you want to use one of them). 

>

even with initial appearances that comply with the text structuring rules for parser interpretation:

The deck plan is a backdrop.
	It is not scenery.
	The initial appearance is "The ship's deck plans are regularly displayed on the walls. ".

However, this is largely acceptable, and I am obviously open to optimizations if they are available.

What happens if, instead of saying paragraph break, you say run paragraph on?

2 Likes

Given that you use the exact same really long condition twice, you may want to consider defining an adjective for it.

Definition: a thing is locale-detailed if
(it provides the property initial appearance) and
(it is not handled) and
(the initial appearance [of it] is not "").

I am not sure whether you need of it in that snippet, which is why I put it in but commented it out. You can also use a thing (called item) and write the item instead of it, if you prefer. Maybe there’s a better name for the adjective; I couldn’t think of anything good.

2 Likes

It works! I had already tested it successfully, but before inserting the terminal paragraph break. Thanks for the reminder.

1 Like

You’re right.

Here is the updated code, for those who might be interested.

A room has a number called expected initial appearances.

Definition: a thing is locale-detailed if (it provides the property initial appearance) and (it is not handled) and (its initial appearance is not "").

Before looking (this is the Before looking - Expected initial appearances counting rule):
	now the expected initial appearances of the location is 0;
	repeat with LocalThing running through locale-detailed things in the location:
		increase the expected initial appearances of the location by 1.
	
For printing a locale paragraph about a thing (called the item) (this is the grouped initial appearance in room descriptions rule):
	if (the item is not mentioned) and (the item is locale-detailed):
		increase the locale paragraph count by 1;
		say "[initial appearance of the item][run paragraph on]";
		[say "[paragraph break]";]
		if (a locale-supportable thing is on the item):
			repeat with possibility running through things on the item:
				now the possibility is marked for listing;
				if (the possibility is mentioned):
					now the possibility is not marked for listing;
			say "On [the item] " (A);
			list the contents of the item, as a sentence, including contents,	giving brief inventory information, tersely, not listing concealed items, prefacing with is/are, listing marked items only;
		[say ".[paragraph break]";]
		now the item is mentioned;
		if (the locale paragraph count is the expected initial appearances of the location):
			say "[paragraph break]";
	continue the activity.
	
The grouped initial appearance in room descriptions rule is listed instead of the use initial appearance in room descriptions rule in the for printing a locale paragraph about rules.

EDIT : I don’t know exactly why, but a “First Carry out looking” rule works better than a “Before looking” rule to count the locale-detailed things and then to activate the final paragraph break.

4 Likes