I have an action for NPCs that should report everywhere. I found the rule that I need to change, but I can’t figure out how to trigger it correctly for the action. Here’s my test room:
"Lucian's Testing Room" by Lucian Smith
Errors1 is a room. Errors2 is east of errors1.
Alice is a woman in errors1. The description is "Alice."
announcing is an action applying to nothing.
Report an actor announcing (this is the report announcing rule):
say "With a squawk, hidden speakers come to life, and you hear [an actor] say, 'Hello, world.'"
every turn:
try alice jumping;
try alice announcing;
A player's action awareness rule
(this is the new player aware of actions by visible actors rule):
[rule succeeds;]
if the player is not the actor and the player can see the actor, rule succeeds;
[when the actor announcing, rule succeeds;]
[if the action is announcing, rule succeeds;]
[when announcing, rule succeeds;]
test me with "z/e"
All the commented-out lines are things I’ve tried that don’t work. The non-commented-out line is the original rule. If I just short-circuit everything with an early ‘rule succeeds’, that works for announcing, but also works for everything else (like jumping). But none of my when/if lines are understood by the I7 compiler.
You almost had it. The problem was you want “current action”, not action, and the current action is being carried out by someone else, so you need to include that too.
A player's action awareness rule
(this is the new player aware of actions by visible actors rule):
if the player is not the actor and the player can see the actor, rule succeeds;
if the current action is someone announcing, rule succeeds;
There was a bug in 6M62 that could cause a memory leak when the current action involved a topic (or other heap-stored value). [EDIT: It only affects stored actions for commands with topics; I was conflating this with another issue.] See I7 compiler bug with translation of "the current action is"?. (I don’t know whether or not this has been fixed in 10.1.)
The ‘After’ solution does indeed work, but worries me semantically a bit. I’m slightly concerned that ‘after’ rules are shown to the player even if they’re not around, but maybe I don’t understand what the point of ‘after’ rules are. Anyway, not only does it work, it’s a good thing to know!
As @Stephen surmised, ‘current action’ was indeed what I was floundering towards, so thanks for that! And then it was also good to know not to use it because of the memory leak bug and slowness, so more thanks there
And finally, @Zed’s solution is clearly semantically what I was going for, and the ‘for’ syntax is not anything I had any idea about, so that’s a nice additional tool in the arsenal.
Isn’t the goal to show it to the player even if they’re not around, though?
The intended purpose of After rules is a bit unclear, honestly. I use them both for things that should happen after an action, and for circumventing the Report rules in specific instances. But using them for both can mean that circumventing a Report also circumvents the aftereffects which is not ideal.
Right, in this case, it does exactly what I want, but now that I know it circumvents everything, now I’m worried about every other ‘After’ rule in the game. Which I apparently should be! So, important safety tip.
Ah, yes. In general, I try to only have After rules print things if they’re triggered off player actions. (After rules on NPC actions are only used for bookkeeping and similar effects.)