A closer look at how actions work across a turn.
last time, on let’s make IF.
Where did we leave things last week? I wrote about the turn as a basic unit of experience and/or play in an Inform 7 game. At a basic, fundamental level, our early efforts as authors will focus on handling player commands (interpreted as actions). Input initiates the turn, there are no turns without input. What comes after player input can be divided into two broad categories:
- Direct responses to the command. Inform 7 will provide feedback specific to player actions, and adjust the state of the game world if needed.
- The invisible machinery operating backstage will operate. This can be invisible to the player. By default, there is a lot happening in an Inform 7 turn, and a lot of it requires no intervention on our part. As we become more capable as authors, we may create background simulation elements of our own.
Since we are just beginning our journey with Inform 7, I will focus exclusively on the first of these two categories. We can make many credible and enjoyable experiences without spending a lot of time on simulation elements. I’ll come back to those later!
creating a custom action.
For this exercise, I’ll create a custom action. Since the Standard Rules contain many built-in, customized responses, the best way to look at the entire processing sequence is to make an action that is separate from that.
frobbing is an action applying to one thing.
understand "frob [something] as frobbing.
As discussed last time, all we need for an action is a present participle and a noun count. In this case, my made-up action “frobbing” involves only one noun: a direct object. On the second line, I define the command grammar that players will use for the frobbing action. We’ve talked about this before: Inform 7 doesn’t know the difference between “sneezing” and “frobbing.” Rather, it provides us with a framework for defining and processing player actions with (mostly) readable English.
Let’s focus exclusively on player feedback (text output) right now. If we want to have frobbing change the state of the game world, we can look at that later. There are several points in action processing where we could ask Inform 7 to process a “frob [something]” command from the player. Here’s the list I provided last time:
- before: the earliest entry point in action processing. happens before many preconditions are checked.
- instead: as the name suggests, “instead” rules are good for redirecting or stopping requested actions.
- check: typically, an evaluation before processing.
- carry out: the action itself.
- after: feedback after the action is complete, typically prevents “report” rules from firing.
- report: a final message or phrase when an action is concluded.
- every turn: just as it says, a rule that is evaluated at the end of every turn. not necessarily specific to the player’s command.
Since “frob” requires a noun. Let’s add one.
apple is in lab.
the description of apple is "It looks quite tasty."
Easy enough! I’ll write up some code for each phase of action processing.
before frobbing the apple:
say "You prepare to frob the apple.".
instead of frobbing the apple:
say "What if you want to do something else instead?".
check frobbing the apple:
say "Hm... is there something you need to do first?".
carry out frobbing the apple:
say "Frobbification in process.".
after frobbing the apple:
say "Now that you've frobbed the apple, you consider your next move.".
report frobbing the apple:
say "Frobbed.".
every turn when the current action is frobbing the apple:
say "I can't believe you frobbed that apple. Nice work!"
OK! That’s each phase of action processing in order. Let’s run it.
>frob apple
You prepare to frob the apple.
What if you want to do something else instead?
I can't believe you frobbed that apple. Nice work!
Hm. Some things are missing! It looks like things stopped after the “instead” rule. Just as the name suggests, “instead” tells Inform to drop the current action and do something else. Instead of frobbing the apple, Inform will print “What if you want to do something else instead?” and halt the action sequence. Check, carry out, etc will never execute. Note that the “every turn” rule still runs; those rules always run unless special efforts have been made to stop them.
Instead is a powerful tool! Be careful with it. Since it stops actions in their tracks, it can prevent you from getting experience with the entire processing sequence. This makes it a bit of a dead end, so try using it just for specific cases where STOPPING or REDIRECTING actions is your intent. I’ll comment out the “instead” rule with brackets. Let’s see what happens now.
>frob apple
You prepare to frob the apple.
Hm... is there something you need to do first?
Frobbification in process.
Now that you've frobbed the apple, you consider your next move.
I can't believe you frobbed that apple. Nice work!
Lots more text there. However, it looks like the “report” output never prints! Why is that? “After” is commonly used to circumvent a stock “report” rule. For instance, there are many “report” responses in the Standard Rules. For instance, we are probably used to seeing “Taken.” as feedback when we as players “take” something in an Inform game. This comes from a “report” rule. If we want to have an action do something other than the standard response, it’s as simple as this:
after taking the apple:
say "You take the apple. It certainly looks delicious!".
By default, Inform will stop processing after an “after” rule. If we did want Inform to continue processing, we will have to say so explicitly:
after taking the apple:
say "You take the apple. It certainly looks delicious!";
continue the action. [note that the standard "taken." response will print now]
This is less common, though continuing “after” can make sense if we are doing some changes to world state. We aren’t doing that yet, though! It is also possible to “continue the action” from an “instead” rule, but I prefer using rules that continue without making special cases.
this seems like a lot.
You might be wondering–I certainly did–“why there are so many phases? Isn’t this overly complicated?” It may be hard to imagine now, but as your game becomes more and more complex, you’ll find that you need ways to make exceptions, to customize responses in more granular ways, and, yes, check and change the state of the game world. We’ll get there! As we will soon discover, it is possible to make rules that are either broad or specific. We can use these different phases to make an orderly world providing general or personalized output as the situation demands. We aren’t there yet, but this is the way.
Here’s a small code snippet featuring today’s content.
“Actions” from the Inform 7 documentation.
next.
Having had a brief look at the different phases of action processing, we can think about ways to think about actions in both general and specific turns. This will involve an early look into world states. We can use values and actions to create dynamic and responsive game worlds. Stay tuned!

Leave a comment