Edit: Oddly enough, in order to test whether an NPC is performing the action, the Instead rule has to NOT include “the actor”. Here’s the final version, which seems to work:
Instead of doing anything when the noun is a magic-spell and the current action is not spellcasting or the second noun is a magic-spell and the current action is not spellcasting (this is the pretend the spell is invisible rule):
I’m trying to write an Instead rule that will do something sneaky – namely, cause the parser, in certain circumstances, to pretend that a backdrop that is everywhere doesn’t exist. This rule needs to let magic-spell casting actions continue but pretend that the spell doesn’t exist if the actor isn’t using a proper spell-casting action.
Here’s the code:
Instead of an actor doing anything when the noun is a magic-spell (this is the pretend the spell is invisible rule):
say "Testing -- the current action is [current action][line break]";
if the current action is casting something:
continue the action;
otherwise if the current action is casting something at something:
continue the action;
otherwise if the current action is zapping:
continue the action;
otherwise:
say "Testing -- in the pretend the spell is invisible rule.";
say "[cant-see-any-such]".
This works fine as long as the PC is the person casting the spell. The problem is, the action doesn’t have the same definition if the actor is not the player:
[code]>cast nitfol
Testing – the current action is casting nitfol
You cast the nitfol spell. Briefly, everything goes dark, but then the light returns.
pip, learn nitfol from book
Pipsqueak finds the page in the book describing the nitfol spell, and commits the spell to memory.
pip, cast nitfol
Testing – the current action is Pipsqueak casting nitfol
Testing – in the pretend the spell is invisible rule.
Pipsqueak can’t see any such thing.[/code]
The current action, as can be seen above, is “Pipsqueak casting nitfol,” so of course the Instead rule puts out a cant-see-any-such error. But this doesn’t work:
if the current action is the person asked casting something:
continue the action;
The compiler complains:
I get the same problem if I use “the actor” instead of “the person asked.” It appears the compiler won’t let me test whether that action is the current action, even though it is the current action. So how can I write the Instead rule in such a way that it will allow those actions (casting something, casting something at something, or zapping), no matter whether the PC or the NPC is trying to perform the action?