Equip potion to be used in battle (visustella available)

Hello makers. This topic was mentioned in the forum, but I couldn't find a good way to implement it, so I need some help.

Visustella can use weapon, armor, or item as skill resource, but it has to be in the inventory, not equipped, so I guess I need to do it in another way.

I found this script:

$gameActors.actor().forceChangeEquip(5, null);

So, I create the 6th armor slot, make the corresponding armor and skill, and bind the skill to the armor, so the skill only shown when I equip the armor. Then, I bind a common event with the script to the skill for deleting the armor after the skill is done. It worked well. My character is healed and the armor(named potion) is gone.

However, I encountere a problem. I don't know how to get the actor ID of the current user of the skill. During test play, I know exactly the character I'm using, so I can directly put the actor ID into the script, but what if I have multiple members in my party. How should I get the corresponding character's ID? I tried something like $subject.battler().ID, but no luck.

Or is there a better way to implement this function?
I'm by no means adept at applying (or understanding lol) script, but I did a quick search in the document in "MZ Script Call List", and I think this should get you the ID for the last actor to act

$gameTemp.lastActionData(2)
Then, I bind a common event with the script to the skill for deleting the armor after the skill is done. It worked well. My character is healed and the armor(named potion) is gone.
alternatively, since youre already using visustella, you can sidestep the common event and have the skill use the script call with one of the skill notetags. benefit of that is that you can just use the "user" reference to get the actor using the skill
I'm by no means adept at applying (or understanding lol) script, but I did a quick search in the document in "MZ Script Call List", and I think this should get you the ID for the last actor to act

$gameTemp.lastActionData(2)
Wow, thank you so much skiz33. Now it works perfectly!

alternatively, since youre already using visustella, you can sidestep the common event and have the skill use the script call with one of the skill notetags. benefit of that is that you can just use the "user" reference to get the actor using the skill
Thank you for replying, Robro33. Do you mean this notetag?

<JS type Cost>
code
code
cost = code;
</JS type Cost>

I've given it a try like below. I made it use 0HP as cost and remove the equipment.

<JS HP Cost>
user.forceChangeEquip(5, null);
cost = 0;
</JS HP Cost>

Yes, it removes the equipment correctly, but the code is executed "before" using the skill, which means the equipment is gone before I choose the skill. That should be because the notetag determents the cost type, so it has to be executed before selecting the skill.

This method seems not to work the way I need, but thank you so much though. I've tried and learned something new today. 😀
Thank you for replying, Robro33. Do you mean this notetag?
nah, not that tag. as youve noticed, that one executes while your skill selection menu is open. i meant using one of the skill tags for doing something upon usage like <JS Post-Apply> and <JS Post-Start Action>
nah, not that tag. as youve noticed, that one executes while your skill selection menu is open. i meant using one of the skill tags for doing something upon usage like <JS Post-Apply> and <JS Post-Start Action>
Cool! Here's my try and it works, too!

<JS Post-Apply>
user.forceChangeEquip(5, null);
</JS Post-Apply>

Thank you Robro33. Like you said, I can save one common event right now. Appreciate. 😀

Original thread: https://forums.rpgmakerweb.com/threads/equip-potion-to-be-used-in-battle-visustella-available.166383/