check eating the rock: say "You can't eat that!" instead
This is how I do it.
In my ever-humble opinion, if Instead rules can be avoided they should be avoided. Which sounds harsh, so try this if you prefer: use Instead rules only when they’re the most appropriate choice.
Likely cases for Before rules:
- you’re redirecting to another action
- the visibility/accessibility/carrying requirement rules don’t need to be checked prior to your rule
Likely cases for Instead rules: you want to test something and potentially end the action in failure and it’s appropriate for this rule to run after the visibility, accessibility, carrying requirement rules but before any Check rules, and you’re using an action pattern or a kind of action.
The name action pattern appears just once in the docs (buried in the Day One example) but it’s the name for things like:
doing something to the cucumber sandwichdoing something other than examining, taking or dropping with the dagger
Given Kissing Mr Carr is unmaidenly behavior, then unmaidenly behavior is a kind of action. “kind” in “kind of action” has nothing to do with what “kind” means everywhere else in Inform and these would better be called named action patterns (or at least that’d be an improvement if the term action pattern itself were better known). @drpeterbatesuk wrote a treatise on action patterns.
Each of Before, After, and Instead is a rulebook. But for each action name there’s a distinct Check, Carry Out, Report rulebook, e.g., Check taking, Check dropping, etc. So you can’t make Check rules for action patterns, named or otherwise.
If you want to test something and potentially end the action in failure and you’re not changing the world state and the rule’s about a distinct action name, not an action pattern, I’d very highly recommend a Check rule.
Now, it’s not necessarily terrible to use an Instead rule instead of a Check rule for that case. I’ll note, though, that my philosophy on errors is that if an action is impossible for several reasons, it’s most appropriate for the game to balk at the most egregiously ridiculous one. If you try to put a bag inside itself, I think “you can’t put something inside itself” makes a better error message than, say, “that seems to belong to…” (and this is, in fact, the default behavior). So I usually want some new potentially-reject-action rule to come after some of the Check rules which, of course, would be impossible if it were an Instead rule.
The thing I’d really jump up and down and scream Don’t do this! about is basically coding the whole action within an Instead rule, a thing that happens repeatedly in the examples. I think that sets a problematic, um, example.
But don’t take my word for it. I once made a collection of Instead rule regrets. Besides those in this thread…
I know I’ve seen more, but I gave up searching after that.
You know how many times I’ve seen someone say “Jeez, I used too many Check rules and now my code is an incomprehensible mess. I wish I’d used more Instead rules” ?
Zero.