version 2 by Jon Ingold
Prevents player from interacting with anything he's not carrying when the location is "currently restrictive", for use when hanging on to ladders or pinned up against the wall by a policeman, and so forth. Two rulebooks are provided for describing what happens.
"Restricted before" is always called in restrictive environments (and should end with "instead" if the action is finished with, "rule succeeded" to continue without and further restriction checks, and "rule failed" if the action should continue to the restricted instead phase where the action will fail.)
"Restricted instead" occurs after a default check that the player is carrying everything he intends to touch, and fails the action if he is not. These rules should supply different and specific failure messages, otherwise a default message will be supplied ( "You can't, because you are .... "). If an instead rule manages to succeed, the action will be allowed after all.
Therefore, if the player is "clinging to the hook on the ceiling" he will need a restricted before rule that says "if the noun or second noun is the hook, rule succeeds" to prevent the player begin told he can't reach the hook. The game will then automatically reject any attempts to interact (other than by examining) objects which are not directly enclosed by the player himself. Finally the "restricted instead" rulebook can be used to supply any outcomes which are specific to the restricted situation: such as telling the player that now is not the best time to be tying his shoelaces or attempting to juggle.
Locations can have a "restriction message", printed in the status line and as a reason from why things can't be reached. (eg. "clinging to the hook", "climbing the ladder").
Rules can be applied "in" the location that's doing the restrictiing:
Restricted before rule in the Narrow Space when jumping
Restricted instead rule in the Rope Bridge when cutting the ropes with the sword
and we can test
if restricted in the location...
if restricted in the Catwalk...