At random

My code for a non-player character showing up at random doesn’t seem to be firing.

Every turn: if player is on A Street: if a random chance of 1 in 4 succeeds: say "[one of]My stars and garters! Look who just stepped out of that limousine! The great Alvin Parsely![or]It[']s Alvin Parsely driving down the middle of the street in a go-cart![or]You can[']t believe your eyes! Is that Johnny Coin walking down the other side of the street?[or]Great balls of fire! Jerry Lee Lunk just walked out of the Kit Kat Club![at random]"; continue the action; otherwise: if player is on B Street: say "[one of]My stars and garters! Look who just stepped out of that limousine! The great Alvin Parsely![or]It[']s Alvin Parsely driving down the middle of the street in a go-cart![or]You can[']t believe your eyes! Is that Johnny Coin walking down the other side of the street?[or]Great balls of fire! Jerry Lee Lunk just walked out of the Kit Kat Club![at random]"; continue the action; otherwise: if player is on C Street: say "[one of]My stars and garters! Look who just stepped out of that limousine! The great Alvin Parsely![or]It[']s Alvin Parsely driving down the middle of the street in a go-cart![or]You can[']t believe your eyes! Is that Johnny Coin walking down the other side of the street?[or]Great balls of fire! Jerry Lee Lunk just walked out of the Kit Kat Club![at random]"; continue the action; otherwise: if player is on D Street: say "[one of]My stars and garters! Look who just stepped out of that limousine! The great Alvin Parsely![or]It[']s Alvin Parsely driving down the middle of the street in a go-cart![or]You can[']t believe your eyes! Is that Johnny Coin walking down the other side of the street?[or]Great balls of fire! Jerry Lee Lunk just walked out of the Kit Kat Club![at random]"; continue the action.

I have tried to contrast the code above with the following code, which I know works, and find no difference:

Every turn when the Hallway is visited: if a random chance of 1 in 4 succeeds: now the ghost is in the location; now the ghost counter is zero; say "[one of]Holy Haunt! There's a presence here -- an apparItition! Jeepers, it's the monster's ghost! You'd better leave -- if that thing touches you, you're dead![or]Babbling Banshees! It's the monster's ghost. Leave NOW! If that thing touches you, you're dead![or]Ponderous Poltergeists! It's the ghost -- and it's right on top of you! GO! If that thing touches you, you're dead![or]Spankin['] Spirits! Get out of here NOW! If that thing touches you, you're dead![or]Gallopin['] Ghosts! It's the monster's spirit! I wouldn't stay here! If that thing touches you, you're dead![or]Spectoratin['] Spectres! You don't want to stay here! It's the ghost, and if that thing touches you, you're dead![or]Sallivatin['] Shades! The ghost! GIT! If that thing touches you, you're dead![or]Sporkin['] Spooks! It's the ghost! Don't let it touch you! If that thing touches you, you're dead![at random]"

Just skimmed over it, and haven’t much time right now, but should you be checking whether the player is “in” A/B/C/D Street rather than “on”?

Also, your indentation is wrong. The way that it is, the code for B, C and D street will never fire. You only get to “Is player in B street?” if you succeed on the “Is player in A street?” check. And of course, if he’s in one place, he can’t be in the other.

Ok, look, the following code works:

[code]B Street is north of C Street. C Street is north of D Street. A room called A Street is north of B Street.

Every turn:
if a random chance of 1 in 4 succeeds:
if player is in A Street:
say “[one of]My stars and garters! Look who just stepped out of that limousine! The great Alvin Parsely![or]It[’]s Alvin Parsely driving down the middle of the street in a go-cart![or]You can[’]t believe your eyes! Is that Johnny Coin walking down the other side of the street?[or]Great balls of fire! Jerry Lee Lunk just walked out of the Kit Kat Club![at random]”;
continue the action;
otherwise if player is in B Street:
say “[one of]My stars and garters! Look who just stepped out of that limousine! The great Alvin Parsely![or]It[’]s Alvin Parsely driving down the middle of the street in a go-cart![or]You can[’]t believe your eyes! Is that Johnny Coin walking down the other side of the street?[or]Great balls of fire! Jerry Lee Lunk just walked out of the Kit Kat Club![at random]”;
continue the action;
otherwise if player is in C Street:
say “[one of]My stars and garters! Look who just stepped out of that limousine! The great Alvin Parsely![or]It[’]s Alvin Parsely driving down the middle of the street in a go-cart![or]You can[’]t believe your eyes! Is that Johnny Coin walking down the other side of the street?[or]Great balls of fire! Jerry Lee Lunk just walked out of the Kit Kat Club![at random]”;
continue the action;
otherwise if player is in D Street:
say “[one of]My stars and garters! Look who just stepped out of that limousine! The great Alvin Parsely![or]It[’]s Alvin Parsely driving down the middle of the street in a go-cart![or]You can[’]t believe your eyes! Is that Johnny Coin walking down the other side of the street?[or]Great balls of fire! Jerry Lee Lunk just walked out of the Kit Kat Club![at random]”;
continue the action.[/code]

All I did was change the indentation, as I said, and change “on” to “in” (dunno if it would have worked with “on”. Maybe it would. Who knows. Who cares). Oh, and I moved the “if one in four succeeds” thing to higher on the hierarchy.

…but you’ll probably want to streamline this a bit! The way it is, if you want to add more streets or change the conditions or change the randomizing text, you’ll have to tweak a lot of things! Try something like:

[code]A room called A Street is north of B Street. B Street is north of C Street. C Street is north of D Street.

The Public Streets is a region. The A Street, the B Street, the C Street and the D Street are in The Public Streets.

Every turn while the player is in The Public Streets:
if a random chance of 1 in 4 succeeds:
say “[one of]My stars and garters! Look who just stepped out of that limousine! The great Alvin Parsely![or]It[’]s Alvin Parsely driving down the middle of the street in a go-cart![or]You can[’]t believe your eyes! Is that Johnny Coin walking down the other side of the street?[or]Great balls of fire! Jerry Lee Lunk just walked out of the Kit Kat Club![at random]”.

The Testing House is north of A Street.[/code]

EDIT - BTW, the specific, game-breaking reasons that the second code you posted works and the first one doesn’t are the resons I gave you: essentially indentation. But the biggest reason that the second is superior to the first is that it’s more compact, more streamlined, and basically it allows you to easily make small tweaks without having to remember to tweak the same thing in four different places!

Okay-dokay. Thank you.