Is there any way to access the current action being performed by a person (and by this I mean actions that have started but haven’t yet finished processing)? This is to be used with actions that can be interrupted by NPCs (if they see the action during the turn(s) it is being performed).
I did this… horrible thing that works for that:
[code]A person has a list of stored actions called myActions.
First before an actor doing anything when the actor is a person and not acting fast:
add current action to myActions of the actor;
Last after an actor doing anything when the actor is a person and not acting fast:
truncate myActions of the actor to ((number of entries in myActions of the actor) - 1) entries;
continue the action;
To decide if (act - an stored action) is the/-- current action for (p - a person):
let entries be number of entries in MyActions of p;
if entries is 0, decide no;
if entry entries of myActions of p is act:
decide yes;
decide no;
[/code]
While it works, it doesn’t look pretty and doesn’t seem very reliable. I think inform somehow thinks that when we do “after” rules we mean “oh, and by the way, do this and nothing else now, okay? This is ALL I want you to do, so please just, you know, stop it all now, it’s fine, I’ll take it from here”. Which means that my code is also very likely to conflict with any future changes (or maybe even built-in code that I don’t know about, unreliable!). So I wonder: is there something built-in function that can be used for this? Or even a more reliable way of doing just this (always execute piece of code before any action, always execute piece of code after any action).
If we only care about the player, we can do “if we are taking the pearl…”, but that one is often unreliable, besides only working on the player. It works well enough to grab the action performed by the player (current user), but it doesn’t grab actions performed by the player (a kind of person). So if one action creates another one (“check taking the pearl: if the box is closed, try opening the box;”), the condition will still return true, as if we were just doing the first action for the whole time.