problem (while the player is in...)

So when I try to put this in Inform 7:

While the player is in Picton Street:
	if a random chance of 1 in 3 succeeds, say "A leaf flutters past.";
	otherwise, do nothing.

it produces the error:

How would I make this work? Is it because the use of ‘while’ here is incorrect?

Thanks in advance. <33

While-clauses do not themselves constitute rules, only conditions on rules, so you need another rule to tack the while-clause onto, such as an every turn rule:

Every turn while the player is in Picton Street: if a random chance of 1 in 3 succeeds, say "A leaf flutters past."; otherwise, do nothing.

Another point worth mentioning is that “the player is in Picton Street” is true only when Picton Street is the (direct) holder of the player – when the player is in Picton Street but not on any enterable supporters or in any enterable containers. So if you have a bench in Picton Street that the player can sit on, your rule won’t fire while the player is sitting on the bench. The way to make sure that the rule fires even when the player is sitting on a bench or something is this:

Every turn while the location is Picton Street:

“The location” is always the location of the player, which is the room the PC is in. (You can also say “the location of the player” where it makes things clearer.) – You might not need this now, but it can help you avoid some headscratching bugs later.

Thank you very much, that helps a lot. :stuck_out_tongue:

If I wanted a similar effect in a game, how could I accomplish this if I wanted it region based, say in the region called “outdoors”.

Also, if I had several random effects, could i do this with a switch?

I’m thinking like:

While the location is in the Outdoor Region: if N is a random number from 1 to 20: 1: say "Random text."; 2: say "Other random text."; 3: say "Different random text."; otherwise: do nothing.

Would that work?

Almost. This would work:

[code]The Outdoor Region is a region.

The Street is in the Outdoor Region.

Every turn when the location is in the Outdoor Region:
let N be a random number from 1 to 20;
if N is:
– 1: say “Random text.”;
– 2: say “Other random text.”;
– 3: say “Different random text.”;

test me with “z/z/z/z/z/z/z/z/z/z/z/z/z/z/z/z/z/z/z/z”[/code]

although this might be a more Informish way:

Every turn when the location is in the Outdoor Region and a random chance of 1 in 7 succeeds: say "[one of]Random text.[or]Other random text.[or]Different random text.[at random]";

You know I am all for putting things in a string like that if they are short, like two or three statements, but I think the structured statements are easier to read when there’s several possibilities. Thanks for the tip.