Scope of a rule?

I have a rule that should only be checked when the player is in HQ. I don’t want the parser to go through every rule all the time.

Before doing anything except saluting, looking, or helping in HQ:
	say "HQ-only command executing";
	if saluteRequired is "True":
		follow the unsaluted rule;

However, the say statement appears everywhere except saluting, looking, or helping commands. I assumed that the rule would only be executed when the player is in HQ.
Am I doing this wrong? How do I restrict the scope of the rule?

I believe the “in” is getting scoped under the “except”. In other words, Inform reads this as:

Before doing anything except (saluting, looking, or helping in HQ)

Instead of as:

Before doing anything (except saluting, looking, or helping) in HQ

This is because “in [location]” is a qualifier on an action. It’s parsed as part of the description of which actions it should apply to.

A “when” clause, on the other hand, is a qualifier on a rule. So if you say “…when the location is HQ”, that’ll be outside the scope of the “except”.


Yep. I changed it to “…when location is HQ” and it worked. Does it shave off any parsing/response time to restrict a rule to a location? I assume it does, but this story is Slooow.

It can, but the speed impact of a rule like this is minimal. If you are having sufficient performance issues that you want to dig in and try to improve things, this thread has some good ideas/resources, though it can be complex stuff:


It can, if the rule does some big tedious calculation (say, calculating a bunch of routes through the map), and then throws away the result if it’s not relevant. But most rules don’t do that.