[Simple] Help with cleaning up this rule

So I want Inform to append a sentence at the end of a description for a container when it is examined saying whether it is open or closed as if it’s a part of the description itself.

After examining a container (this is the container state rule): say "[The noun] is [if the noun is closed]closed[otherwise]open[end if].".
My code here works, it lists it fine, but there’s a line break (or paragraph break?) between the description and the statement.

How do I get this printed on the line after the description rather than two lines later?
I assume I have to tell Inform where the rule takes place but I don’t quite know how to get that far yet

The issue has taken place before your rule had a chance to run. The “examine containers rule” which prints the “In the box is…” text prints a period, which causes an automatic paragraph break–and I think that even without that, Inform would supply an automatic paragraph break when the rule ended. (It can be pretty tricky to figure out when Inform is throwing in paragraph breaks sometimes.)

The way to fix this would be to tell the examine containers rule not to put in the automatic paragraph break. This can be done by putting “[run paragraph on]” at the end of its text substitutions. In most cases, you could do this by replacing rule responses like this:

The examine containers rule response (B) is "[The noun] [are] empty. [run paragraph on]".

but unfortunately one of the text substitutions we need to change isn’t labeled as a rule response (it’s just “.”). So we have to rip out the old examine containers rule and replace it with a new one, with “[run paragraph on]” in the right place:

[code]Carry out examining (this is the new examine containers rule):
if the noun is a container:
if the noun is open or the noun is transparent:
if something described which is not scenery is in the noun and something which
is not the player is in the noun:
say "In [the noun] " (A);
list the contents of the noun, as a sentence, tersely, not listing
concealed items, prefacing with is/are;
say “. [run paragraph on]”;
now examine text printed is true;
otherwise if examine text printed is false:
if the player is in the noun:
make no decision;
say “[The noun] [are] empty. [run paragraph on]” (B);
now examine text printed is true;

The new examine containers rule is listed instead of the examine containers rule in the carry out examining rulebook. [/code]

On a quick test, this seems to work… at least in the case I tested.

Another thing is that once you’re substituting a new rule for the examine containers rule, it seems like you might as well put your line about whether the container is open or closed at the end of this rule rather than making a special rule for it:

Carry out examining (this is the new examine containers rule): if the noun is a container: if the noun is open or the noun is transparent: if something described which is not scenery is in the noun and something which is not the player is in the noun: say "In [the noun] " (A); list the contents of the noun, as a sentence, tersely, not listing concealed items, prefacing with is/are; say ". "; now examine text printed is true; otherwise if examine text printed is false: if the player is in the noun: make no decision; say "[The noun] [are] empty. " (B); now examine text printed is true; say "[The noun] is [if the noun is closed]closed[otherwise]open[end if]."; now examine text printed is true.

This also has the advantage of giving us a chance to cut off “You see nothing special about the box.” in the case where the box is closed and we’re about to print the container status (try examining a closed container that doesn’t have a description with your code and you’ll see what I mean). After we print the status, we set “now examine text printed is true” which tells the last carry out examining rule that we’ve printed something, so don’t say “You see nothing special about the box.”

You might also want to restrict this to openable containers, though the quick attempts I’ve tried to do that have reintroduced all kinds of wacky spacing issues.

Note that if you have a container with its own description, this won’t put the rule results on the same line as the container’s description. You’ll still get something like:

or

If you want to take care of that, you have to do something similar to the “standard examining rule,” which puts a line break after the description of the thing. You’d want to make sure that your change only applies to containers.