MV Notebox Function Function

I made an action point system using Yanfly plugins. Now, not every skill uses this AP system but most does. And what uses it runs the exact same code every time which is
(x is the AP cost)

Code:
//Action Point Setup

//This makes the skill not end turn.
<Instant>

//This controls the actual requirement that the game uses to determine if the skill can be used or not.
<Custom Requirement>
 if (a.ap >= x) {
   value = true;
 } else {
   value = false;
 }
</Custom Requirement>

//This controls what the UI displays next to the skill as a requirement.
<Custom Cost Display>
 x
</Custom Cost Display>

//This controls the loss of Action Points after the skill was used.
<Custom Execution>
   a.addCParam(0, -x)
</Custom Execution>

It works without an issue, I'm just wondering if there's any way I don't have to copy paste this whole thing into every skill notebox and just simply write it similarly to a Javascript function?
I don't have the sufficient coding knowledge to do anything beyond this.

The following plugins are used in this:
IMO, if this is going to be a thing that your game features in a large number of skills, you could try to make a copy of the skill core or the cooldown plugin and modify it into a dedicated AP plugin.

Offhand, youd just need to at minimum... hook into Game_Battler.canPaySkillCost and paySkillCost to handle the cost aspect, then adjust the notetag parsing functions to read an AP notetag so that it could be handled automatically with something like <AP Cost: x>, and then adjust Window_SkillList.drawSkillCost or drawOtherCost to handle the display

itd be a bit of a project if youre new to it and are willing to do it, but if you know enough to read whats happening in the plugins itd be a decent learning experience

Edit: Also

I've moved this thread to Javascript/Plugin Support. Thank you.

I made an action point system using Yanfly plugins. Now, not every skill uses this AP system but most does.

My danger sense is tingling. Are you sure it's not just easier to paste this into 50 skills? The code doesn't change, right?
IMO, if this is going to be a thing that your game features in a large number of skills, you could try to make a copy of the skill core or the cooldown plugin and modify it into a dedicated AP plugin.

Offhand, youd just need to at minimum... hook into Game_Battler.canPaySkillCost and paySkillCost to handle the cost aspect, then adjust the notetag parsing functions to read an AP notetag so that it could be handled automatically with something like <AP Cost: x>, and then adjust Window_SkillList.drawSkillCost or drawOtherCost to handle the display

itd be a bit of a project if youre new to it and are willing to do it, but if you know enough to read whats happening in the plugins itd be a decent learning experience

Edit: Also Moved to: Javascript/Plugin Support
Yes, this is my problem. I can' read those plugins. XD
I can barely read the core JS files and do small edits to plugins but the way these plugins function is beyond my level unfortunately. If it requires more extensive coding, I'll pass as I have tried learning to code but it just fried my brain hard.
Thank you for moving it into the right place, I had a feeling I placed this into the wrong forum. XD
My danger sense is tingling. Are you sure it's not just easier to paste this into 50 skills? The code doesn't change, right?
I mean, it is easier but since I want to write a lot more things into the noteboxes, it's going to be very hard to read through the skills.
As for the code, let me check my notes... yes, the codes stays the same for every skill which uses action points.

Original thread: https://forums.rpgmakerweb.com/threads/notebox-function-function.179350/