Picking the highest variable out of many variables

There are 7 variables for 7 events. I don't know how to make the specific event occur if the variables are the highest compared to the other variables.
Are you looking for something like this?


Code:
var tempArray = [$gameVariables.value(101), $gameVariables.value(102), $gameVariables.value(103), $gameVariables.value(104)];

Array.max = function( array ){

return Math.max.apply( Math, array );

};
Are you looking for something like this?


Code:
var tempArray = [$gameVariables.value(101), $gameVariables.value(102), $gameVariables.value(103), $gameVariables.value(104)];

Array.max = function( array ){

return Math.max.apply( Math, array );

};
idk what this is to be honest. So basically I have 7 event tied to 7 variable and whichever variable is highest thats the event to occur.
Can you explain a little more? What sets the variable? Are the variables different items the player collects? I feel like there are probably ways it can be evented but without knowing exactly what you are trying to do, it is hard to know what to advise.
its like a quiz where u answer different questions and each answer will add more to each variable. Each variable is like for each stat: atk def, etc.
So I want the biggest variable for e.g they answered correctly for the question their attack will increase. But if they answered more questions correctly for defense oriented questions they get more defense.
Pseudocode for Variable Comparsion: Eventcommand "Script":
Code:
bex = 0
$gameVarables.setValue(8, 0)
for (var a = 1; a <= 7; a++) {
  if ($gameVariables.value(a) > bex) {
    bex = $gameVariables.value(a)
    $gameVarables.setValue(8, a)
  } }
We are checking the variables 1 to 7 and game variable 8 will contain the id number of the variable with the highest value.
So you can use Variable 8 for further Eventing or for your Eventpage conditions.
If 2 Variables have the same value, than the one with lower id will be choosen as the higher one.

Edit:
I posted this Loop Snippet, because this saves you from having to make a big amount of conditional branches and all the math with events. Events sadly dont have this variable pointer function. I read in rm2k or rm2k3 that they had it in the editor as standard.
The Eventing way to do it would be to set an 8th variable to 0, then compare the 8th variable to each of the other 7 variables, and if the other variable is higher than the 8th variable, then set the 8th variable equal to its value. After doing it all 7 times, the 8th variable will be equal to the highest value from the other 7.

Then, if you need to find which variable was the highest of the 7, create a 9th variable, and compare this new 8th variable to each of the original 7 variables again - this time, if the values are equal, use the 9th variable to store the ID of the variable that it matched. So for example, if Variable #3 matches Variable #8, then set Variable #9 to the value "3".
He can do that the first Time he goes through them. No need for a second loop. But yes 9 Variables he need.
In the script snippet above i just used 8 game variables and a 9th temporary one that is deleted the moment the snippet finishes.
He can do that the first Time he goes through them. No need for a second loop. But yes 9 Variables he need.
In the script snippet above i just used 8 game variables and a 9th temporary one that is deleted the moment the snippet finishes.

Correct, and in fact that's how I generally do it when I don't use code, but I find it's much easier to conceptualize as two separate runs through the variables.
I needed some help with this too. But im using 12 variables. a few points will be distributed into each variable once each question is answered and i need it to use the variable with the highest variable. once thats done, i need it to act on that variable. Any tips on how to do this?
Necro-post notice: @Jade010

Your question also does not seem the same as the OP's (but like the OP you need to provide more information). Please start your own thread describing in more detail what you are doing and what result you are after.

Original thread: https://forums.rpgmakerweb.com/threads/picking-the-highest-variable-out-of-many-variables.104847/