Every turn rules with two or more random 'say' phrases

In a game I am making, I have a location where I want two different types of random statements to be printed–or not–using a ‘if a random chance of 1 in 3 succeeds’ clause with the [one of][at random] format, so that often one sentence, or two sentences, or nothing, is printed. But in the case that two sentences, one from each group, is printed, I want them to have a blank space between them. I found that this can be done if I write two Every turn rules, one for each group–I guess because a rule with a ‘say’ phrase will automatically print a paragraph break–even if the two rules are stated identically…?

Every turn when the location is River Crossing:
if a random chance of 1 in 3 succeeds:
say “[one of]The stream continues rushing under the bridge, making gurgling noises close to the shore.[or]You see a wasp–or was it a mayfly?–dance over the weeds.[or]A brisk wind blows your hair around for a moment.[or]You hear the leaves rustle in the trees nearby.[at random]”.
Every turn when the location is River Crossing:
if a random chance of 1 in 3 succeeds:
say “[one of]An eft skitters over the bridge surface.[or]You hear the nearby mining crew whistle a mining tune.[or]A fish hops out of the water, then dives back in.[or]A squirrel picks up a nut and then deftly runs up a tree.[at random]”.

Is there a better way to do this, under one rule, so that if two sentences are printed, a paragraph break divides them??

Thanks.

Whoops, first I used the ‘code’ brackets in copying my code into my posting, but it didn’t come out right. Then I took off the brackets and tried to use spacing to get it right, but that didn’t seem to do anything. How do we write code into our postings here?

Thanks.

1 Like

Does any of this work?

1 Like

The surest way to avoid an auto paragraph break is to defer end-of-sentence punctuation or put a space after it inside the quotes:

River Crossing is a room.

Every turn when the location is River Crossing:
	if a random chance of 1 in 3 succeeds:
		say “[one of]The stream continues rushing under the bridge, making gurgling noises close to the shore. [or]You see a wasp–or was it a mayfly?–dance over the weeds. [or]A brisk wind blows your hair around for a moment. [or]You hear the leaves rustle in the trees nearby. [at random]”;
	if a random chance of 1 in 3 succeeds:
		say “[one of]An eft skitters over the bridge surface[or]You hear the nearby mining crew whistle a mining tune[or]A fish hops out of the water, then dives back in[or]A squirrel picks up a nut and then deftly runs up a tree[at random].";
River Crossing

>z
Time passes.

You hear the nearby mining crew whistle a mining tune.

>z
Time passes.

The stream continues rushing under the bridge, making gurgling noises close to the shore. An eft skitters over the bridge surface.

>z
Time passes.

A brisk wind blows your hair around for a moment. A squirrel picks up a nut and then deftly runs up a tree.

Reading back, it sounds like you do want a paragraph break - you said “space” but I think you meant line break (carriage return). In this case, I put in a [command clarification break] which sort of works at the expense of an extra line break - which at least seems consistent as you should get the same amount of white-space before the command prompt whether one or both lines fire.

Every turn when the location is River Crossing:
	if a random chance of 1 in 2 succeeds:
		say “[one of]The stream continues rushing under the bridge, making gurgling noises close to the shore.[or]You see a wasp–or was it a mayfly?–dance over the weeds.[or]A brisk wind blows your hair around for a moment.[or]You hear the leaves rustle in the trees nearby.[at random][command clarification break]”;
	if a random chance of 1 in 2 succeeds:
		say “[one of]An eft skitters over the bridge surface[or]You hear the nearby mining crew whistle a mining tune[or]A fish hops out of the water, then dives back in[or]A squirrel picks up a nut and then deftly runs up a tree[at random].";
River Crossing

>z
Time passes.

>z
Time passes.

You hear the leaves rustle in the trees nearby.

An eft skitters over the bridge surface.

>z
Time passes.

You see a wasp-or was it a mayfly?-dance over the weeds.

>z
Time passes.

The stream continues rushing under the bridge, making gurgling noises close to the shore.

A squirrel picks up a nut and then deftly runs up a tree.

>z
Time passes.

You see a wasp-or was it a mayfly?-dance over the weeds.

>z
Time passes.

>z
Time passes.

A brisk wind blows your hair around for a moment.

>z
Time passes.

The stream continues rushing under the bridge, making gurgling noises close to the shore.

A fish hops out of the water, then dives back in.

>z
Time passes.

You see a wasp-or was it a mayfly?-dance over the weeds.

You hear the nearby mining crew whistle a mining tune.

>z
Time passes.

The stream continues rushing under the bridge, making gurgling noises close to the shore.

An eft skitters over the bridge surface.

>z
Time passes.

A squirrel picks up a nut and then deftly runs up a tree.

>z
Time passes.

A brisk wind blows your hair around for a moment.

>z
Time passes.

>
1 Like

The most fail-safe way is to paste the code in, highlight it, and then hit the code button above the text box. (It looks like </>.)

If you want to use keyboard only, you can try prefacing everything with four spaces:

There's four spaces before this line.
And this one.

This one too.

But you have to make sure that you put blank lines before and after.
I put four spaces before this line and it didn’t accomplish anything.

(Also in my browser, you can’t type a tab into a text box, so I have no advice for how to do that without pasting code in and then using the </> button.)

Also, line break handling is one of the nastier bits of Inform 7. See threads here and here.

1 Like

Sorry, guys, I haven’t had a chance to respond till now. Thanks a lot, I will try your suggestions!

If you’re going to be writing tons of these randomized messages per room, especially if they have different conditions for their firing or you only want fewer than a certain number to fire per room per turn, it may be worth creating dedicated rulebooks for them so each message can live in its own rule. The default rule-sorting behavior in I7 usually produces the expected outcome from a rulebook with a big mess of heterogenous rules.

If so, check out Chapter 19.

1 Like

Thanks, Chris, that’s food for thought.