Each before/instead/after are being consulted with each and every action. This was debated in this thread and various other places.
before/instead/after can be used on non-specific actions:
Before doing something other than examining or approaching to something which is not within the location:
However, they are mostly used on specific actions:
Before going through the Pearly Gates:
Before going a squared-off direction:
Before going through a closed door (called the blocking door):
So maybe Inform should only consult ‘Before going’ when an actor is going - and not with each and every action - the same way that ‘check going’ works.
Would this be a moderately easy hack, or is it one of those things that just isn’t worth it?
As far as I can tell, this would require rewriting parts of the I7 -> I6 translator to have it make separate rulebooks for each action. Right now, the behavior of Before is the same as any other I7 rulebook; “check going” is a single rulebook all its own, as is “check eating” and “check jumping” and so on.
The ability to write a “before” rule for multiple actions is pretty important.
Although, really, it should be possible to write a “check” rule for multiple actions. The current system is an awkward compromise between expressivity and efficiency.
Okay … rules are rigidly seperated into:
- multiple action rules: (before/instead/after)
- specific action rules: (check/carry out/report)
So “before going” will be invoked with every action, even though it obviously is linked to a specific action (going).
Likewise “Check doing something” won’t work, because check only works with specific actions.
I was thinking, maybe there is some practical reason for the rules to be seperated into those that only work for specific action, and those that work for all actions?
“Specific action” ones are a bit more efficient, since they avoid the small overhead of a function call and return when they aren’t needed. But they don’t let you handle the fairly common use case of one rule affecting multiple actions.
Ideally the compiler could do that optimization for us, placing rules which apply to only one action in a specific rulebook. But it would be a lot of back-end work for not much improvement; it might be more effective to e.g. hand-tune the indexed text code further, or find some way to mechanically optimize expensive “every turn” rules.
But sometimes authors will want a Before going rule that runs in between two multi-action Before rules, so they all have to be in the same rulebook anyway.
The compiler cannot optimize about what rules are in what rulebooks, for that reason. It can optimize how it generates rulebook functions. For example, it could use a switch statement rather than a chain of ifs where that’s appropriate.
(However, this runs into the problem that an I6 switch statement is a chain of ifs, so that wouldn’t actually save any time.)
Perhaps I missed this upthread, but is it because “Instead” “Before” and “After” are their own gigantic single rulebooks, and something like “Check taking the candlestick” is a more specific “check taking” rulebook?
So you can “Instead of unmaidenly behavior” but you can’t “check unmaidenly behavior”.
[on edit} Ah, yes. Draconis said it upthread.