MZ Items and Equips Core VisuStellaMZ

I'm wondering how to make potion only usable for a certain actor:
JavaScript:
<JS Item Enable>
 if (user == $gameActors.actor(3))
    enabled = true;
 else
    enabled = false;
</JS Item Enable>
I used this and set the scope of an item to "user" but that doesn't work as I wanted it to do, because outside the combat it detects the user based on formation order and not the person who's being targeted by the item. Is there a way to make it work outside the combat, so I don't have to shuffle the entire party every time I want to use the item?
This kind of restriction is unfortunately harder than just checking who was targeted; JS Item Enable only affects whether it's possible to *select* the item. You can restrict who it actually works on using a comparison with $gameParty._targetActorId, but then if you *try* to use the item on someone it doesn't work on and come out of the menu, you can't use the item again because target actor ID no longer matches the actor.
This kind of restriction is unfortunately harder than just checking who was targeted; JS Item Enable only affects whether it's possible to *select* the item. You can restrict who it actually works on using a comparison with $gameParty._targetActorId, but then if you *try* to use the item on someone it doesn't work on and come out of the menu, you can't use the item again because target actor ID no longer matches the actor.
Yeah, I realized that. That's why created this thread, do you know a way to check who is selected before confirming the use of an item?
what is the intended effect of the item? If that effect can be simulated by common event, the event can check target before applying

edit: ninja'd
Yeah, I realized that. That's why created this thread, do you know a way to check who is selected before confirming the use of an item?
The best I can do is making the item non-consumable, giving it no standard traits, and then doing

<JS Post-Apply>
if ($gameParty._targetActorId === id of actor) {
// do whatever the item does
$gameParty.loseItem($dataItems[id of item], 1);
}
</JS Post-Apply>
what is the intended effect of the item? If that effect can be simulated by common event, the event can check target before applying

edit: ninja'd
The best I can do is making the item non-consumable, giving it no standard traits, and then doing

<JS Post-Apply>
if ($gameParty._targetActorId === id of actor) {
// do whatever the item does
$gameParty.loseItem($dataItems[id of item], 1);
}
</JS Post-Apply>
That's what I wanted to avoid, but I'll do that if I don't find a way to check who's being selected.
Okay, I spent my last 2 hours digging through RMMZ code and finally found a satisfying solution, and if anybody encounters similar problem here's the solution I produced:

JavaScript:
<JS Item Enable>
let index = SceneManager._scene._actorWindow.index();
let actor = SceneManager._scene._actorWindow.actor(index);
let visible = SceneManager._scene._actorWindow.visible;
if (actor == $gameActors.actor( put id of an actor here ) || !visible)
   enabled = true;
else
   enabled = false;
</JS Item Enable>

@Edit
I really want to hit my head against the wall after seeing how easy it was.
Nice! I'll have to keep that one in mind.

Original thread: https://forums.rpgmakerweb.com/threads/items-and-equips-core-visustellamz.137128/