Check, Carry out and Report...

I am probably opening a can of worms, here, or perhaps I should know better, but often I find myself content to write rules for actions in this way—

Check grumbling: if the location is not Dining Room: instead say "A stern look from your ship captain silences you." After grumbling: say "You pitch a fit about the latest encroachment upon your personal space."

My games seem to work well with this format. Of course, I use Before and Instead rules where needed, but most of my rules setups are of the form above. Yet I read/hear time and again that it is bad form to not use Check, Carry out and Report rules, especially after creating a new action. I find I tend to use an After rule, in the place of Carry out and Report–I type out the instructions to the program and any ‘say’ phrases associated with the action under ‘After’.
When is it more appropriate to use Check, Carry out and Report?? And what is the difference (I figure it probably makes a difference in terms of the flow chart of actions and how/when other rules may intervene, plus clarity to those who may be reading my code)?

Thanks.

1 Like

Generally, for your own personal games, so long as your code works the way you want it to, whatever you do is fine.

If you’re writing an extension that other people are going to use, you need to put the rules in the correct phases so the rules they write will work properly and you won’t short-circuit an action by having things happen at the wrong time.

If you’re going to write parser games and use Inform to do complicated things, you probably should learn when to use what rule phase. Things will just go a lot better if you cooperate with the parser and let it do its job.

1 Like

I don’t think there are universal answers to “when you should use what rule phase”. A lot depends on what parts of Inform you’re making use of.

In particular, if you don’t depend on action success/failure, you get a lot more leeway in what you can put where.

1 Like

Zarf is right. Inform gives an author a lot of flexibility on ways to do things. I use headers, but I probably use Volume, Section and Part. NEVER CHAPTER OR BOOK. Or something. One of them doesn’t indent the outline hierarchy and I, therefore, shun it.

1 Like

Thanks to you both!

I believe that the intent, broadly speaking, is that check, carry out, and report are meant to house the “default” behavior of an action, while before, instead, and after handle specific situations.

Check contains the fundamental, sanity-check rules of when an action is or isn’t allowed to proceed (e.g., you can’t take something if you already have it; you can’t take something that is fixed in place; etc.). Carry out houses any rules that change the game state when the action occurs under normal circumstances (e.g., now the noun is carried by the player). Report provides the default game response (“Taken.”).

The conceptual difference between before and instead can be a bit fuzzy, but I find it helps to bear in mind that before rules do not halt the action by default, while instead rules do. Thus, before is suited for rules that cause things to happen, but then allow the action to proceed as normal (e.g., “You do a few stretches and make sure to bend at the knees,” before attempting to take something heavy), while instead handles situations that should prevent the action from occurring (e.g., instead of taking something hot, say “Yow! That’s hot!”). Finally, after is meant to provide non-default game responses (“The grapefruit squishes slightly when you pick it up”). That’s why it comes before the report rules and normally supersedes them.

To sum up:

  • Before - situational rules that should happen before the action begins but then allow the action to continue
  • Instead - situational rules that should block an action from happening before it begins
  • Check - default rules that decide when an action is or is not possible under normal circumstances
  • Carry out - default rules that change the game state (e.g., moving things around, setting properties, etc.)
  • After - situational rules for customized game responses
  • Report - default rules for default game response

That being said, it is also definitely true that “best practice” is whatever works best for your game. Some authors like to load all of their action-blocking rules, situational or otherwise, into check, or load all of their game responses into report. Sometimes it works better for a before rule to stop the action, or for an instead rule to let the action proceed. And so forth. There is a neat sort of logic to the way the rulebooks are arranged, but that logic won’t always hold for every situation or make perfect sense to every author.

As others have mentioned, there are a couple of niche situations in which you’d want to pay closer attention to where you’re putting your rules. One is when writing extensions. The other is when you need to keep track of whether an action “succeeded” or not. Inform decides this based on (I think) whether the action got all the way through the carry out stage without being blocked. So, for example, consider these two rules:

[code]Instead of smelling the barbecue: say “Smells delicious!”

After smelling the barbecue: say “Smells delicious!”
[/code]
From the player’s perspective they do exactly the same thing. However, from Inform’s perspective, the first rule prevents the smelling action from happening, while the second rule does not. This is often a trivial distinction, but sometimes it can be significant, such as when writing conditions about the past tense (e.g., “if the player has smelled the barbecue” will return false if the instead rule is used, but true if the after rule is used.

5 Likes

Thanks Mike!!