MZ [Solved] How can I define functions for damage calculation in a plugin?

Edit: Solved - just needed to add the following at the top of the .js file:

/*:
* @target MZ
*/


I'm trying to make a plugin to hold my damage formula (example below). However, I keep getting 0 damage, which seems to be the default for when a formula's invalid. If I open the debug console (F8), I don't see any errors getting thrown. However, if I write 'my_formula', I get an uncaught reference error so presumably I didn't properly scope my function.

How can I fix this so I can use my function in the 'formula' section for skills? The example here's short, but sometimes the formulas get long and it's annoying to type/scroll through the little textbox.

Example (.../js/plugins/my_plugin.js):

function my_formula(a, b) {
return a.atk * 4 - b.def * 2;
}


I have imported my plugin and made sure it's active (on).
Just to clarify: adding @target MZ to the header literally only suppresses the "this plugin may not be compatible with MZ" warning in the Plugin Manager.

I imagine you just forgot to save your project to apply Plugin Manager changes before testing. (I do that a lot myself.) In that case you would see changes made to the database, e.g. your new damage formulae, but not any changes made to the plugin load order or active status.
This thread is closed due to being marked as solved. If you need it reopened, report the thread to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/solved-how-can-i-define-functions-for-damage-calculation-in-a-plugin.172395/