How to make an X value into a range?

When writing an x value into a notetag, how can I make it into a range instead of a static number?
My game has an ATB system and I'm trying to make it so each player character starts with their ATB gauge filled up to a random amount between 0 and 50%. With the Yanfly ATB plugin I know how to make them start with a flat percentage, e.g. <ATB Start: +25%>, but I don't know how to make it random within a range. Does anyone have a solution?
I'm guessing you'd have to edit the plugin function that parses that notetag to take two arguments instead of one (minX, maxX), then add in additional line of code within that function to randomly pick a number between the minX and maxX values.
I just had an idea -- can I make the x value reference a variable? I could make a common event set a variable to 0-50 and then call it up in the notetag.
No. You must follow the syntax for notetags in plugins as it says in their instructions.

When it tells you to supply a value, you have to type a value. As a rule, you can only use JavaScript if the instructions say you can.

That's what @AquaEcho was getting at in the first reply, the plugin would have to be recoded to change what it accepts there.
That's very close-minded. There are many creative ways of approaching a problem.

I'm guessing you'd have to edit the plugin function that parses that notetag to take two arguments instead of one (minX, maxX), then add in additional line of code within that function to randomly pick a number between the minX and maxX values.
I don't understand. Can you be more specific?
That's very close-minded. There are many creative ways of approaching a problem.
I have no idea what you're talking about. You asked if you could type something into a notetag other than what the instructions say can go there, and I said no, that's not how code works.
There are many creative ways of approaching a problem.
And the answer is to "creatively" add that function into the plugin's code.
If you think it can work, then just try inserting the js there:

Code:
$gameVariables.value(69)
Where 69 is the ID number of the variable you want to use.
It doesn't take but half a minute to try it out yourself and see whether it can parse the JS in a note tag or not.
And if it can't parse the js, then:
No. You must follow the syntax for notetags in plugins as it says in their instructions.
You could also combine the two solutions and edit that plugin function to skip reading the notetag altogether and just use $gameVariables.value(69) or whatever.
The main issue is that all data is only loaded once so even with the variable, it will not work the way you want unless you call the function before battle.

This is not fool proof but I'll give it a shot.

You will need to make a few changes to the function (as shown below - save it as a js file to overwrite the Yanfly one).

Before every battle, you will need to run a script call before your battle processing IF you want to change the value of it.

Spoiler
JavaScript:
DataManager.processATBNotetags2 = function(group, bool) {
  var range = bool ? Math.randomInt(101) / 100 : 1;
  var noteA1 = /<(?:ATB START):[ ]([\+\-]\d+)>/i;
  var noteA2 = /<(?:ATB START):[ ]([\+\-]\d+)([%%])>/i;
  var noteB1 = /<(?:ATB TURN):[ ]([\+\-]\d+)>/i;
  var noteB2 = /<(?:ATB TURN):[ ]([\+\-]\d+)([%%])>/i;
  for (var n = 1; n < group.length; n++) {
    var obj = group[n];
    var notedata = obj.note.split(/[\r\n]+/);
    obj.atbStartFlat = 0;
    obj.atbStartRate = 0;
    obj.atbTurnFlat = 0;
    obj.atbTurnRate = 0;
    var evalMode = 'none';
    obj.atbHelp = undefined;
    for (var i = 0; i < notedata.length; i++) {
      var line = notedata[i];
      if (line.match(noteA1)) {
        obj.atbStartFlat = parseInt(RegExp.$1 * range);
      } else if (line.match(noteA2)) {
        obj.atbStartRate = parseFloat(RegExp.$1 * 0.01 * range);
      } else if (line.match(noteB1)) {
        obj.atbTurnFlat = parseInt(RegExp.$1 * range);
      } else if (line.match(noteB2)) {
        obj.atbTurnRate = parseFloat(RegExp.$1 * 0.01 * range);
      } else if (line.match(/<(?:ATB HELP)>/i)) {
        evalMode = 'atb help';
        obj.atbHelp = '';
      } else if (line.match(/<\/(?:ATB HELP)>/i)) {
        evalMode = 'none';
      } else if (evalMode === 'atb help') {
        obj.atbHelp = obj.atbHelp + line + '\n';
      }
    }
  }

The script call can be accompanied with a boolean (true or false, or leave it out completely) and must be run before the battle if you want to change it:
Spoiler
JavaScript:
DataManager.processATBNotetags2($dataActors, true);
The script call takes two parameters: the database items ($dataActors, $dataSkills, etc.) you want to evaluate again and a true or false. if you leave the 2nd parameter blank, it will keep it at whatever your notetag was set. If you set it to true, it will be a percentage of what you put down (between 0-100).

Hope this helps. I tested it with a vanilla project and it works for me. If you are feeling creative, you are welcome to make the changes to fit your needs.
That's very close-minded. There are many creative ways of approaching a problem.
not to beat the topic to death, but even though a plugin can be made to do anything, it can only do what it was written to do. most of the notetags provided by yanfly plugins unless stated otherwise do not accept JS because they were written to expect a certain kind of input and handle it a specific way.

without having the know-how to check and see what it does or even edit it to do what you want, the best you can do is to test it out and ask about it if it doesnt work out

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-an-x-value-into-a-range.173287/