Script to compaire multiple variables

Ok so im making a game with natures (bold, hasty, quiet,...ect). At the start of the game the player is asked 8 random questions out of 64 questions(yes i know thats alot of questions). When answering a question certain answers will give +1or +2 points to a certain nature(will be controlled by a variable ofcourse). Then at the end of the questioning you will be asked if your a boy or girl, Every question Minus the "boy or girl" question will give you points towards certain natures. At the end of the questions i want it to pick the highest variable to base the character on. so it would be like this
 

Spoiler
Nature  |  Boy      |   Girl
Bold     | Char1   | Char1fem 
Brave   | Char2   | Char2fem
Calm    | Char3   | Char3fem
Docile  | char4    | Char4fem
Hardy
hasty
Impish
Jolly
Lonely
Naive
Quiet
Quirky
Rash
Relaxed
Sassy
Timid
and you get the picture. each nature has a different character graphic and each gender also has a different character graphic what i need a script for is to keep track of all 16 variables and how many points they get from the 8 questions so that i can say "oh hasty got the most points from the 8 questions and the character chose Girl so they get this char graphic" or "Calm got the most points from the 8 questions and the player chose boy so they get this char graphic", i already have the 64 questions set up to randomize through common events all thats left is to find a way to keep track of the highest variable. So if anyone can help me i would greatly appreciate it
insert this script

class Game_Interpreter def highest_var_id(*args) return args.sort {|a,b| $game_variables <=> $game_variables[a]}[0] endendTo use, write down in script call in control variables, choose another variable id that you don't use it yet to record the id of the highest variable value

highest_var_id(1,2,3,4,5) # you dan add more variable ids as much as u wantThen start use conditional branch

I've not tested by myself. But I'm sure it will works.
class Game_Interpreter def var_max(array) array.each do |id| varmax=id if !varmax varmax=id if $game_variables > $game_variables[varmax] end return varmax endendUse in conditional branch: script:
Code:
varmax([array of var id])
Ex:
Code:
varmax([1,3,5,7,8,9])
Will check variable 1,3,5,7,8,9And return the variable id with

The highest value.

Edit: ninja'd 😛 . above post solution will be better. Since you have the whole order. You can know the number 2 highest variable too.
i dont need to know the 2nd highest. just the highest

My condition branch looks like this

@>conditional branch: Script: varmax([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]) @> :Else @> :Branch End@>what else do i need to do to make it return the highest variable?
if you want to know the highest, Insert this script to script editor

class Game_Interpreter def highest_var(*args) args.collect {|id| $game_variables[id]}.max endendEnter the script call, write down this line

highest_var(1,2,3,4,5,6)It will return the highest value from the compared variables
I suggest using theo code. It's more clean.

To use that. It's better to put it in a variable first. Use change variable event command: script:

Code:
highest_var(1,2,3,4,5,6)
Then use that variable in conditional branch. Variable equals to 1, equal to 2. Etc.
what? .. that just confused me so badly..
I think he was assuming that you're gonna do different things that is specific to the value of the max

Like

If Max == 1

elseif Max == 2

elseif Max == 3

which is why he suggested to save it first into another variable...
im still tryin to figure out what he means by change variable event command :script: 

if hes talking about making a variable = script i cant. the script is to long for the script box

Edit:the script fits in the conditional script box but not the variable script box
you can do like:

Scripts: 

vars = [0,1,2,3,4,5,6,7,8] and so on until you hit end of line

vars.push(add more here)

and so on then

$game_variables[index] = highest_var(vars)

That is assuming it's fine to send an array variable to the method...
im so confused.. do i link the var.push script to the same Variable as the vars= script?
no, vars is the collection of the variable numbers that you wish to get the maximum of... the max value is saved in the $game_variables[index] line

vars = [0,1,2,3,4,5,6,7,8] and so on until you hit end of line

vars.push(add more here)

$game_variables[index] = highest_var(vars)
btw, I'm not sure if .push can take an array as argument
well where am i suppose to add it then.. do i just put them all in script calls?

it would be nice if i could actualy see how it was done.. would make things alot easier for me to understand
yeah... in the script call command... a single script call command will do as you can put multiple lines there...

anyway, that's only if the numbers don't fit... 

btw, if you're looking into an arithmetic series of variables

like 1,2,3,4,5,6,7,8,9

I think it's worth trying to just use

highest_var(1..9)
its just 1-16. thats the variables im trying to compare
try doing highest_var(1..16)

but anyway, if it fits to the variable set-up line, then you have no problems anyway
i still have no clue what your talking about..
Grab the demo if you still don't get it

https://dl.dropboxusercontent.com/u/41797508/VXA/highest%20var%20demo.exe
$game_variables[index] = highest_var(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)

assuming it fits

and index is the index of the game variable where you will save the highest var...

if it doesn't fit, you can try

$game_variables[index] = highest_var(1..16)

example:

If I want to save that value to variable 17, then I'd do

$game_variables[17] = highest_var(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
Ahh i forgot to put the variable in the index spot in the script call XD now it finaly stopped giving me an error so im assuming this is correct now?

VariablesCompare.png

Original thread: https://forums.rpgmakerweb.com/threads/script-to-compaire-multiple-variables.17123/