[MV] Affection Values

I pretty much want to rip off of Tales of Symphonia.
For those who haven't played that game, usually you have 2 or 3 dialogue choices (Like slight approvals or disapprovals towards characters), every character who isn't the protagonist has one, and the choices increase them. Eventually, if the gauge is high enough, the character has extra dialogue or extra scenes.
At a certain point in the game, characters with the highest value show up, and that's where I'm struggling.

With variables, I can emulate the gauges. However, I cannot make a command that checks whose gauge is highest.
Is there a plugin for this?
You can actually make an event that sets a variable to this script:
Code:
var x = function(){var variables = [INSERT YOUR VARIABLES HERE]; var highest = $gameVariables.value(variables[0]); var index = 0; for(var i = 1; i < variables.length; i++) { if ($gameVariables.value(variables) > highest) { higest = $gameVariables.value(variables); index = variables; } } return index;}; x();

This will compare the variables and set it to the highest of them. By doing it like this you wont have to add a plugin. However, if you want it could quickly be hidden in a plugin instead 🙂

EDIT: Made the plugin as it will look more clean in the editor.
Code:
//=============================================================================
// HighestVariable.js
//=============================================================================

/*:
 * @plugindesc This plugin let you call a function that compares and returns
 * the id of the variable with the highest value.
 * @author Magnus0808
 *
 * @help Call the method DataManager.FindHighestVariable(VariableID_Array);
 *    E.g: DataManager.FindHighestVariable([5, 3 , 2]);
 */
(function() {
    DataManager.FindHighestVariable = function (variables) {
        if(!variables || variables.length == 0) return null;
       
        var highest = $gameVariables.value(variables[0]);
        var index = 0;
        for(var i = 1; i < variables.length; i++) {
            if ($gameVariables.value(variables[i]) > highest) {
                higest = $gameVariables.value(variables[i]);
                index = variables[i];
            }
        }
        return index;
    }
})();
Thank you! I'll be sure to credit you

Original thread: https://forums.rpgmakerweb.com/threads/mv-affection-values.105436/