Message for failed actions

By “blank line” do you mean:

> chew tree with me
>

or

>chew tree with me

>

? I’m assuming it’s the first, since nothing in the code you provided suggests it would be the second.

Writing in Inform: New Actions

When you create an action, 3 rulebooks are created, e.g., Check Chewing, Carry Out Chewing, Report Chewing. There are 3 other action rulebooks that are followed for all actions except out of world actions: Before, Instead, After. And a few other action-processing rules…

The order is Before rules, then visibility (if this action was defined as requiring light, do we have light? n.b.: this does not have to do with saying “applying to a visible thing” in the action definition), accessibility (if this action was defined as requiring a touchable thing, the default if you just say “thing”, can the player touch the thing) and carrying requirement rules (if the action was defined as applying to a carried thing, is the player carrying the thing).

Then the Instead Rules. If an Instead rule triggers, the default is that the action fails unless the rule includes continue the action (that’s why you don’t get to any After rules). After Instead are the Check rules.

The action might fail during any of those. The visibility, accessibility, and carrying requirements rules are all about testing whether the action should fail. The intent of the Check rulebook is that that’s where you put tests to see if something fails.

But once you’re beyond the Check rulebook and into the next, the Carry out rules, the action is a success by definition.

With new actions, there’s simply no output by default. Unless a Before or Instead rule causes some output, or there’s an error message from one of the tests between Before or Instead, it’ll say nothing. So the absence of output you’re seeing is typically an action succeeding, but having no Report rules defined (though you could write a Before or Instead or Check rule that could make it fail without output if you tried.)

So rather than thinking of it as “say something unless there would be no output” it might be easier to think of it as: “say something or not” knowing that not saying anything is the default.

You might want to personalize things with individual messages per action, but if you really want a default “That failed”, then when you define new actions you can make them a kind of action (no relation to the more usual meaning of “kind” in I7).

Chewing is a default-message action.
Crumping is a default-message action.
[...]
After a default-message action, say "That failed."

It’s a lie – so far as I7’s concerned the action succeeded. But you’re the author and you get to lie as much as you want.

Of course, the above is not especially shorter, and perhaps less clear than just:

check chewing: instead say "That failed."
check crumping: instead say "That failed."

These both assume that the successful version is implemented with, say an Instead or Before rule redirecting to another action, as in your example.

Then, just to wrap up, after the Carry out rules are the After rules. Like Instead, these default to ending the action immediately if they don’t include continue the action. And, finally, the Report rules, typically the place where output for successful actions lives.

Guidelines on how to write rules about actions