Lack of Paragraph Break problem with example 354

Hello again,

This is driving me slightly nuts. I’m using this slightly doctored example from the I7 manual (it’s from example 354: “Air Conditioning is Standard”).


A person has some text called current occupation. The current occupation of a person is usually "None". 

After writing a paragraph about a person (called X):
	let the subsequent mention be "Name";
	if the current occupation of X is not "None":
		say "[current occupation of X]. ";
		let the subsequent mention be "He";
		if X is female, let the subsequent mention be "She";
	if X carries something unmentioned:
		if the subsequent mention is "Name", say "[The X] ";
		otherwise say "[subsequent mention] ";
		say "is carrying [a list of unmentioned things carried by X]."

My problem is that, if the NPC in question is not carrying something unmentioned, it prints only "[current occupation of X]. "; ---- which is fine, except that the space at the end of that line means there’s no line break between that line of description and the command prompt. If X carries something unmentioned, of course, it goes ahead and prints the line about the things carried and prints a line break underneath.

I’ve tried various things. Putting the space before the [subsequent mention] (that didn’t work). Putting a space and [run paragraph on] before [subsequent mention] didn’t work either. What DID work, kind of, was this:


A person has some text called current occupation. The current occupation of a person is usually "None". 

After writing a paragraph about a person (called X):
	let the subsequent mention be "Name";
	if the current occupation of X is not "None":
		say "[current occupation of X]. ";
		say "[run paragraph on with special look spacing]";
		let the subsequent mention be "He";
		if X is female, let the subsequent mention be "She";
	if X carries something unmentioned:
		if the subsequent mention is "Name", say "[The X] ";
		otherwise say "[subsequent mention] ";
		say "is carrying [a list of unmentioned things carried by X]."

That [run paragraph on with special look spacing] does exactly what it says on the tin, ie:

Except that for reasons unknown to me, it also repeats the [current occupation of X]! Any idea why?

Thanks in advance,

Jason Guest

Rather than messing around with different kinds of line breaks, I really would just add more “if” statements.

I also use the print-punctuation-first-and-last idiom for stuff like this.

After writing a paragraph about a person (called X):
	if the current occupation of X is not "None" or X carries something unmentioned:
		let the subsequent mention be "Name";
		if the current occupation of X is not "None":
			say current occupation of X;
			let the subsequent mention be "He";
			if X is female, let the subsequent mention be "She";
		if X carries something unmentioned:
			if the subsequent mention is "Name":
				say "[The X] ";
			otherwise:
				say ". [subsequent mention] ";
			say "is carrying [a list of unmentioned things carried by X]";
		say ".".

This is not perfectly-reduced code in the sense that you would usually strive for in most programming tasks. But it solves this problem without using obscure properties of the line-break system. It also lets you tune the output later. For example, you could change the period between the two causes to a semicolon.

As for your second question:

With your second example, I don’t see it repeating the occupation. Instead I see this (setting up an example with Steve the firefighter, with no unmentioned objects):

Basically this happens because the library’s internal logic has the line

if a paragraph break is pending: [...] now the item is mentioned;

In your first example (and my code) this winds up giving Steve the mentioned property. In your second example, you change the linebreak state so that that “if” doesn’t trigger, so Steve is unmentioned, so Steve gets collected into a you-can-also-see paragraph.

You can fix that by adding “now Steve is mentioned”. But, again, it’s not necessary with my code.

Ah, thanks Zarf. I had a hunch I would need to add more if statements to that chunk of code but I had become completely fixated with line breaks.

And yes, the weird-seeming behaviour of [run paragraph on with special look spacing] makes sense once you separate it from my already convoluted code.

  • Jason