Script call when using item.

Has anyone made a plugin where you can make a script call when using an item?


Sure you can just make the item call a common event, but having to link each items (I have a lot) to a common event is pretty messy.


I'm looking for something that can be put on the item note tag that will run a script when used. eg:

(this is a potion that increase in effectiveness the more you use it)


Note:


<script call>


$gameVariables.setValue(n, $gameVariables.value(n)+1);


user.gainHp($gameVariables.value(n));


</script call>
I am not super experienced in writing plugins, but writing a common event paired to a variable sounds like the most stable way to do this.


Use the exact formula you have there and viola.
um ... damage formula?
um ... damage formula?

Can variable or switch be altered using damage formula?
sure can.  Just put the commands separated by a semi-colon into the damage formula, making sure the last command results in the actual damage amount.


So for your example, you'd set the item to HP Recover, and put this in the formula:

Code:
$gameVariables.setValue(n, $gameVariables.value(n)+1); $gameVariables.value(n)

You won't need the user.gainHP because just putting variable n at the end will make that the amount to recover.
Ohh, didn't know that!


Thanks for helping me out!

Original thread: https://forums.rpgmakerweb.com/threads/script-call-when-using-item.66354/