Action Processing — Summary

The table below (which was suggested by Michael Callaghan) shows all of the stages Inform goes through when processing a player’s command — or rather, all of the stages Inform normally goes through. The action processing can be stopped at every stage. If it’s stopped at a given stage, none of the later stages will be reached.

Stage Comment Outcome How to change
Parsing The player’s input is checked to make sure it makes sense — that all of the words are spelled correctly and so on. If the input makes sense, Inform 7 next goes on to check Scope. If the input doesn’t make sense, an error message is displayed. It’s possible to modify how the parser understands the player’s input, but this is an advanced topic not covered in the Handbook. For details on how to use the “After reading a command” feature, see p. 20.6 in Writing with _Inform,_especially Example 412.
Scope Where the action involves one or more things, Inform 7 checks that the things referred to are in scope. With some exceptions, things that are in scope are in the same room as the player. If the things are in scope, Inform 7 checks the Before rules. If the things are not in scope, an error message is displayed. There are two ways in which scope can be changed. The first, discussed in this chapter, is where the action affects “[any thing].” The second is to write some special code that will place something in scope when it would otherwise not be. This is an advanced topic not covered in the Handbook. For examples, you can search the Documentation for “scope,” noting especially Examples 209 and 226.
Before rules All Before rules are contained in a single rulebook that Inform consults to see if any of them applies to the action that is now being processed. The default outcome after consulting the Before rules is to make no decision, so that Inform 7 proceeds to consider touchability. To indicate that a Before rule has succeeded (in doing something) and stop processing the action, use “rule succeeds”.
Accessibility Inform checks that even if something affected by the action is in scope (see above), it needs to be visible and touchable if the action involves touching it. If an object is in a closed glass container, for instance, the player will be able to EXAMINE it but not TAKE it. If the thing cannot be touched, if it’s hidden, or if the room is dark, an error message is displayed. The easiest way to bypass the accessibility test is to intervene using a Before rule.
Implicit actions Certain verbs trigger an implicit action. For example, the EAT command causes an implicit taking action if the item to be eaten is portable and is not being held by the player. If the implicit action fails, an error message is displayed. If you don’t want the implicit actions to be triggered, the easiest way to do this is to intervene using a Before rule.
Instead All Instead rules are contained in a single rulebook that Inform consults to see if any of them applies to the action being carried out. The default outcome for the Instead rulebook is failure. If any Instead rule applies, the action processing stops with the outcome “rule failed” unless you add “continue the action” or “make no decision” at the end of the Instead rule. If we want an Instead rule to stop the action with the result that the action succeeded, we can use the words “rule succeeds”.
Check rules Every action has its own Check rulebook. If you are creating new actions, this is where you will set out any preconditions that apply to the action being carried out. The default outcome from the Check rules is to make no decision and proceed to consider the Carry out rules. To specify that a Check rule has succeeded and stop processing the action, you can use “rule succeeds”.
Carry Out rules Every action has its own Carry Out rulebook. If you’re creating new actions, you’ll usually want to write a Carry Out rule that handles what’s supposed to happen. The default outcome from the Carry Out rules is to make no decision and proceed to consider the After rules. Normally, you should not need to change the default outcome from the Carry Out rules.
After rules All After rules are contained in a single rulebook that Inform consults to see if any of them applies to the action being carried out. The default outcome for the After rules is success. If an After rule applies, Inform stops processing the action. You won’t often need to change the default outcome of an After rule. But if you want Inform to go on to the Report rule, end your After rule with “continue the action”.
Report rules Every action has its own Report rulebook. When you create new actions, write a Report rule to print out the messages that will be displayed to the player if no preceding rule has succeeded or failed. The default outcome for the Report rules is success. As this is the last stage of processing the action, it is not appropriate to use “rule fails”, “rule succeeds” or “instead”.