making skills usable only when a variable is fulfilled

I want to make a skill that's only usable when a variable is above or below a certain value. How do i do this? My game involves a special battle mechanic. The game seems to only let you set required weapons and not variable conditions. Also, i would like to have certain event pages in the troop activates when variables reaches a certain number. If there isn't an option to do this, is there a plugin that let me do so?
I want to make a skill that's only usable when a variable is above or below a certain value.
You'd use Visustella Skills and States Core, the JS Skill Enable notetag.
Code:
<JS Skill Enable>
enabled=$gameVariables.value(X)>Y;
</JS Skill Enable>

The above means the skill is only enabled if variable ID X is greater than the number you replace Y with.
Also, i would like to have certain event pages in the troop activates when variables reaches a certain number.
This is a little trickier, because troop conditions are coded into the editor and plugins can't change the editor, only the game.

There is a plugin that lets you code your own conditions with event commands, though, so you can check that out:
For the first part. Skill Conditions. I can point you to the rmmz_objects.js which is where you'll find the .meetsSkillCondition function. This is where it performs checks for skill cost, possible Sealed Effects and other requirements.
So you can add on requirements here.
In the skill database you can add meta data to individual skills like,
<requirement: 5>

So the line you want to add to the function might be something like
skill.meta.requirement ? Number(skill.meta.requirement) <= $gameVariables.value(1) : true
Which is evaluating 2 things at once.
First, if the skill has requirement data at all - otherwise return true
Second, if that data matches whatever variable - true or false.

But as I'm typing this, I realize it would probably be better to use
skill.meta.requirement ? eval(skill.meta.requirement) : true
writing the condition statement in meta data like this, since you might have different skills dependent on different variables.
<requirement: $gameVariables.value(1) >= 5 >

Either way should work.
[img]https://i.imgur.com/qYGmdvi.png[/img]

Original thread: https://forums.rpgmakerweb.com/threads/making-skills-usable-only-when-a-variable-is-fulfilled.147764/