SOLVED: Testing What Action

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?

I don’t think you can use variables in names of actions like that (that is, Inform would understand “Bob casting something” but not “the person asked casting something”). Does “if the action name part of the current action is the casting action” work? There may be a more elegant way.

I think you need “if the current action is an actor casting something”?

Or do kinds of action work for NPCs? I think they do. Then something like this might work, perhaps:

[code]Casting is spellcasting. Casting something at something is spellcasting. Zapping is spellcasting.

Instead of an actor doing anything when the current action involves a magic-spell and the current action is not spellcasting:[/code]

You also probably need to catch the case where the magic-spell is the second noun, which “involves” should cover.

Good try, but no cigar. Here’s my new rule:

Instead of an actor doing anything when the noun is a magic-spell or the second noun is a magic-spell and the current action is not spellcasting (this is the pretend the spell is invisible rule): say "Testing -- the current action is [current action][line break]"; say "Testing -- in the pretend the spell is invisible rule."; say "[cant-see-any-such]".
“involves” wasn’t compiling for me, so I specified both the noun and the second noun explicitly. This next line has to follow my definitions of the new actions, but it compiles:

Casting is spellcasting. Casting something at something is spellcasting. Zapping is spellcasting.

Whether it is being applied in the Instead rule is harder for me to determine. Here’s the output – substantially as before:

The Instead rule works properly when the player is the actor, but when Pip is the actor, the Instead rule can’t identify the action. Here are the actions themselves:

[code]
Zapping is an action applying to two things. Understand “[magic-spell] [something]” as zapping.

Carry out an actor zapping:
try the actor casting the noun at the second noun instead.

Casting is an action applying to one thing. Understand “[magic-spell]” and “cast [something]” as casting.[/code]
I don’t see any problems there. One doesn’t normally need to say “the actor” when defining a new action, does one?

On the theory that I don’t understand how I7 processes long conditionals, I tried this:

Instead of an actor 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):

Same result. It compiles, but it thinks Pipsqueak’s action is not spellcasting.

One thing about the long conditionals is you can use parentheses, so this would do what it looks like:

Instead of an actor doing anything when (the noun is a magic-spell or the second noun is a magic-spell) and the current action is not spellcasting (this is the pretend the spell is invisible rule):

As for the other stuff, I’m not sure and can’t really check until I have time to fire up I7 again. Have you tried Draconis’s suggestion?