Trouble with Inform 7 line/paragraph breaks...

I have been struggling with this and just don’t know what’s happening or how to figure it out. Okay, so here is an example to show the issue:

[code]“Test”

Example Location is a room.

Rule for printing a parser error:
carry out the Testing activity.

The testnumber is initially 0.
Testing is an activity.
Rule for Testing:
now the testnumber is the testnumber plus 1;
if the testnumber is 1:
say “Testing.”;
if the testnumber is greater than 1:
try MoreTesting.

MoreTesting is an action applying to nothing.
Carry out MoreTesting:
say “More testing.”[/code]

When you play this and type in a parser error, let’s say you just type the letter V, then the game prints “Testing.” with a single line break underneath. If you then type the letter V again, the game prints “More testing.” and there are two line breaks underneath.

Does anyone know how to stop it from printing a second line break? (Or maybe it’s a paragraph break. I have no clue. I just want to turn it off.) Thank you!

Try putting a space after any period within quotes where you don’t want Inform to assume a paragraph break.

“This is a finished sentence.”

This should run on with another sentence within the same rule or at least only single line break. "

This falls under the general heading of “invoking an action or rulebook buys you an extra newline.” (This is not a universal rule; there are specific linebreak situation where it’s true.)

Actually, the thing I just cited would have caused an extra newline before the message. So it’s not quite the same thing.

You could try changing the message to

say “More testing.[conditional paragraph break]”

But I don’t know if that’s always right. It seems to be right for this test case.

Really, the best plan is to be consistent – always invoke an action for that parser error case.

Sorry, I should’ve clarified that I also want MoreTesting to be able to be triggered normally. So this is the example I should’ve given from the start:

[code]Example Location is a room.

Rule for printing a parser error:
carry out the Testing activity.

The testnumber is initially 0.
Testing is an activity.
Rule for Testing:
now the testnumber is the testnumber plus 1;
if the testnumber is 1:
say “Testing.”;
if the testnumber is greater than 1:
try MoreTesting.

Instead of going north, try MoreTesting.
MoreTesting is an action applying to nothing.
Carry out MoreTesting:
say “More testing.”[/code]

Hanon, your suggestion won’t work, I’m afraid, because then there’s no line break at all when the MoreTesting action is triggered normally by going north.

zarf, adding “[conditional paragraph break]” appears to have the same result as Hanon’s suggestion. Good when funneled through Testing, but no line break normally.

I should also mention that this isn’t a one-time case in the game I’m writing. I need Testing to be able to funnel into many different actions, which is why I want to stop the extra line from being added at that Testing activity stage, rather than addressing every possible action result. But it sounds like I might have to do that…

Shoot. Is it [command clarification break]?

No, with [command clarification break] there’s still no line break when going north.

If it’s an extra line break on following a rule, this thread might be helpful: https://intfiction.org/t/line-breaks-on-following-rules/7973/1

I’ll check out that other thread! In the meantime, I just figured out a horribly clunky way to work around the issue with variables. It involves changing the actions, not the Testing activity, but at least it’s a start.

[code]“Test”

Example Location is a room.

Rule for printing a parser error:
carry out the Testing activity.

The errornumber is initially 0.
The testnumber is initially 0.
Testing is an activity.
Rule for Testing:
now the errornumber is 1;
now the testnumber is the testnumber plus 1;
if the testnumber is 1:
say “Testing.”;
if the testnumber is greater than 1:
try MoreTesting.

Instead of going north:
now the errornumber is 0;
try MoreTesting.
MoreTesting is an action applying to nothing.
Carry out MoreTesting:
say “More testing[if the errornumber is 0].[otherwise]. [end if]”[/code]

This is only marginally better, but you could ditch the errornumber variable and do this:

Carry out MoreTesting :
	say "More testing.";	
	if the Testing activity is going on:
		say "[run paragraph on]";

That does seem to work as well! I’m not sure whether it’s better for my particular game, since the mechanics are slightly more involved than I’ve pared them down to for these examples, but I’ll try it out and see what’s easiest.

Thanks for the help, everyone!

I use this code in Flexible Windows to make the line break status of the outer code completely ignore that of the called activity:

To safely carry out the (A - activity on value of kind K) activity with (val - K): (- @push say__p; @push say__pc; CarryOutActivity( {A}, {val} ); @pull say__pc; @pull say__p; -).

You’d be able to do something similar for actions. It might help.

That type of programming looks beyond me, unfortunately. But it’s okay. What I have now seems to be working, albeit awkwardly, but all my code is awkward so we’re par for the course.