Can you stop the calling action from a phrase?

Is is possible to do something like this:

carry out fooing the bar:
    unless the bar is purple, fail with "The bar should be purple.";
    try eating the bar;

to fail with (msg - a text):
    say "[bold type]Failure -- [msg][roman type]";
    stop the action;

What I mean is this: in the carry out rule there’s a sort of assertion (“unless the bar is purple”), and if this fails it calls a phrase (fail with…), and then in that phrase, I would like to stop the entire carry out fooing action.

My hunch is that this either cannot be done at all, or at least only in very circuitous ways. But I am always prepared for the case that I am missing something fundamental in Inform7.

If the rules reach the Carry Out stage, the action is deemed to be successful. All failure checks must occur before you reach this stage. You need to write a Before, Instead, or Check rule.

Check fooing the bar when the bar is not purple: instead fail with "The bar should be purple.";

Carry out fooing the bar: try eating the bar.

Right, that makes sense, thanks. I need to rethink what I was trying to do I think.

Hi,

Another way to do it, if you have several check rules that have similar tests, is to use a rule instead of a phrase:

Code:

Check fooing the bar:
follow the wrong bar color rule;
if rule failed, stop the action;
try eating the bar instead.

This is the wrong bar color rule:
unless the bar is purple, say “[bold type]Failure – [msg][roman type]”;
rule failed.

Neil

I don’t know what I was thinking. Actually, the rule should read:

This is the wrong bar color rule:
unless the bar is purple begin;
say “[bold type]Failure – [msg][roman type]”;
rule fails;
end unless.

Yeah… Hm.

maybe I should tell y’all what I was actually trying to do and see what you can come up with.

I wanted to do a sort of “fast forward” command for beta testers (and, not least, myself). I know you can do this with “test” scripts and maybe using the skein. But I thought it would be neat to be able to do scripts that would play through moves, and also perform assertions about the game state as the game progresses.

Maybe I can do this with Danii’s unit test extension?

Essentially I would like the game to do stuff like this:

try opening the box
Assert the box is open
Try taking the apple
Assert the player is carrying the apple
Assert the apple is red
Assert the worm is in the apple
Try going north

Edit: or even better:
parse “open box”
Assert the box is open
Etc

Am I making sense?

You might try Aaron Reed’s Intelligent Hinting for this. It would be able to take care of making your assertion true if it fails, and for fast-forwarding through puzzles to later parts of the game.

You cannot define an I7 phrase that stops the action, because “stop the action” is literally an I6 “return” statement.

However, you can do it in an I6 phrase, because these are included inline and a “return” is effective there.

to fail with (msg - a text):  (-
    print "Failure -- ", (PrintText) {msg};
    rtrue;
-).

Needless to say this is hackiness of a high order. (And I’ve done it.)