Multiple of the same rule

Hey,

Been working with Inform 7 for a bit now and have a few questions:

  1. If an extension I’m using has an “After examining:” rule, if there any way for me to also have an “After examining:” in my story as well? It seems as if the first one declared overrides any subsequent ones.

  2. I have the following declared in my story:
    An Item is a kind of thing.
    Using it on is an action applying to two things.
    Understand “use [item] on [thing]” as using it on.
    ItemA is an item.
    ItemB is an item.
    SpotForItemA is a thing.
    SpotForItemB is a thing.

Carry out using ItemA on SpotForItemA:
say “ItemA used”.

Carry out using ItemB on SpotForItemB:
say “ItemB used”.

Only the carry out for ItemA works. It ignores the ItemB carry out. If i change the second one to “carry out using ItemB on SpotForItemA”, it works. I’m assuming its working something like the “every turn” problem from above, but I am not sure.

Thanks for any help.

The second problem is easy: “SpotForItemA” and “SpotForItemB” are indistinguishable to the parser, because it only looks at the first nine characters. When you type “use itemb on spotforitemb”, the parser sees “use itemb on spotforit”; there are two indistinguishable spotforit objects; the parser chooses the first one. If you give the spots better names, this problem will go away.

If you have two rules that both read “After examining:”, then yes, only the first one will apply. That is because After rules have a default outcome of success. What’s happening is that Inform 7 first checks if there are any After rules that apply in this situation, and finds two. It then checks which of these rules are the most specific. Since both are equally specific, it evaluates them in turn, until it reaches an outcome, which ends the execution of that particular rulebook. This is why the second rule does not fire.

As for a way to have an “After examining” rule override that behavior, simply make your After rule more specific. It will then have higher precedence than the general “After examining” rule.

[code]A gemstone is a kind of thing.
The diamond, the sapphire and the ruby are gemstones.

There is a room. All gemstones are here. The rock is here.

After examining the diamond: say “[The noun] is absolutely flawless.”
After examining: say “[The noun] is otherwise unremarkable.”
After examining a gemstone: say “[The noun] sparkles prettily.”[/code]

It doesn’t matter if you rearrange the order of these rules in the source code. They will still behave the same way.

You can change this by ending the rule with “continue the action”.

Awesome, thanks for the quick and helpful responses. That completely solves the issues I’ve ran into. Thanks for the help!