A phrase called by a "before" rule can't stop the action

Hello,

Here is a mini-game of something I am trying to do: I have a “before attacking” rule that calls a phrase. The phrase has several outcomes, some of which require the attacking to stop and others for it to continue. How do I do it? The problem is that this scheme does not work and the action continues, regardless of the “stop the action” line.

[code]The Arena is a room.

The Gladiator is a man in the arena. The gladiator can be angry or ticklish. The description of the Gladiator is “The Gladiator is [if angry]angry[else]ticklish[end if].”

After touching a ticklish gladiator:
say “Now the gladiator is angry.”;
now the gladiator is angry.

After touching an angry gladiator:
say “Now the gladiator is ticklish.”;
now the gladiator is ticklish.

Before attacking the gladiator:
call for backup.

Instead of attacking the gladiator:
say “You come victorious out of this one.”

To call for backup:
if the gladiator is ticklish:
say “Three more of your friends come and help you confront the poor Gladiator. At least, he dies laughing.”;
now the Gladiator is nowhere;
else:
say “Nobody wants to come and confront an angry gladiator.”;
stop the action.[/code]

That’s correct. The “stop the action” phrase works by returning a particular value, which is only meaningful in the rule body, not in functions called by the rule.

You could redefine the “call for backup” phrase as returning a value.

To decide whether successfully calling for backup: [decide yes or no]

You’ll end up with something like this. Also, you’ll want the “now the Gladiator is nowhere” bit in the instead area since the gladiator will be “nowhere” for the attack during instead if you remove him during the before phase. And you’ll want to specify the gladiator as starting out angry.

The Arena is a room.

The Gladiator is a man in the arena. The gladiator can be angry or ticklish. The gladiator is angry. 
The description of the Gladiator is "The Gladiator is [if angry]angry[else]ticklish[end if]."

After touching a ticklish gladiator:
	say "Now the gladiator is angry.";
	now the gladiator is angry.
   
After touching an angry gladiator:
	say "Now the gladiator is ticklish.";
	now the gladiator is ticklish.

Before attacking the gladiator:
	if not successfully calling for backup:
		stop the action.

Instead of attacking the gladiator:
	say "You come victorious out of this one.";
	now the Gladiator is nowhere.

To decide whether successfully calling for backup: [decide yes or no]
	if the gladiator is ticklish:
		say "Three more of your friends come and help you confront the poor Gladiator. At least, he dies laughing.";
		decide yes;
	else:
		say "Nobody wants to come and confront an angry gladiator.";
		decide no.

Yes, this makes sense.

I’ve never actually used the [decide yes or no] form, so its good to hear about it.

I suppose an alternative would be to create a variable and give it a value of 0 (fail) or 1 (success) and then check that value in the before rule. But that would be more useful if there were more than 2 possible outcomes.

Although I sense that the “decide” can also be used for more than just 2 options, as in:

[decide yes, no, maybe, or probably not]

or

[decide yes or no or maybe or probably not]

:smiley:

“Decide” is equivalent to “return” in other languages. “Yes” and “no” are equivalent to “true” and “false”. That’s probably an easier way to think about it.

You can write rulebooks with multiple defined outcomes.

See inform7.com/learn/man/WI_19_12.html