Let’s say I have a switch that causes something random to happen when pulled, but that action would only happen once, and once only. Essentially, it’s removed from the list of possible actions to happen after it’s triggered.
It’s an exception. That sounds like a good reason to use an Instead rule.
[code]The Cavern is a room. “A cavernous cavern.”
Some rocks are a thing. “Huge rocks lie here.”
The suspicious lever is a thing. The initial appearance is “A suspicious-looking lever protrudes from the wall.” It is fixed in place in the cavern. Instead of trying pulling the lever for the first time, have the player trigger a cave-in. Instead of pulling the lever, say “The lever is stuck.”
To have the player trigger a cave-in:
say “You pull the lever. With an ominous rrrrumble, rocks begin to fall, and you leap aside just in time.”;
now the rocks are fixed in place in the cavern.[/code]
As for whether that constitutes a good or clean way of doing it, I’ll defer to more experienced authors. The above works and is, I think, reasonably succinct.
Hm, I read this a little differently than Eleas. I was thinking you were looking for a lever that when pulled, triggered a random event from a list of possibilities and then if pulled again, would trigger a different random event. This would continue until all the possible events were triggered (only one time each) and then some sort of default would be triggered.
This scenario made me think of text substitutions, which can execute code in addition to (or instead of) printing text. There are also a variety of different ways to randomize them using the “[one of]” tag (see ch 5.7). Anyway, this is what I came up with:[code]Lab is a room. The lever and a magic ball are in Lab.
North of Lab is a locked door called a red door. South of Lab is a locked door called a blue door.
North of the red door is the Back. South of the blue door is the Front.
After pulling the lever:
if we have pulled the lever more than three times,
continue the action; [<-- goes to the default report rule (“Nothing obvious happens.”)]
otherwise say “[one of][option 1][or][option 2][or][option 3][in random order]”.
To say option 1:
now the red door is unlocked;
now the red door is open;
say “The red door opens.”
To say option 2:
now the blue door is unlocked;
now the blue door is open;
say “The blue door opens.”
To say option 3:
now the magic ball is off-stage;
say “The magic ball dissappears!”
test me with “n / s /pull lever / g / g / g / x magic ball / n / s / s”.[/code]