[RPMXP] need help finding largest variable out of 7

Hello! I'm very new here and to coding/scripting. I'm trying to make a personality quiz for my game that will determine what starting item they will be given, out of 7. While i know that this is possible with nesting conditional branches, that's gonna get messy very quickly. I've tried to search for scripts that other people have used/shared, but I haven't found one that works with XP. (or maybe I'm messing them up)

The variables I want to compare are numbered 51-57, and Ii have 58 reserved to take on a value(1-7) dependent on the maximum value of 51-57, which will be used to indicate which item will be given. I just need a script to help me find the max value between var51-57 and assign a number (1-7) to var 58. I think i can figure out the rest.

Any help would be much appreciated!!! Thank you!!
Ruby:
# * Game Variable ID with Highest Value
#   2023-06-15

# - Get Index value of the Highest Game Variable
#   Returns a Game Variable ID
# $game_variables.max_var_id(range)

#   Example:
# $game_variables.max_var_id(1..10)

class Game_Variables
  def max_var_id(range)
    values = @data[range]
    max_value = values.max
    values.index(max_value) + 51
  end

  def max_var(range)
    var_id = max_var_id(range)
    @data[var_id]
  end
end
thank you so much for your quick reply!
However, I'm a little confused still, i assume I put this as a new script under the Tools>script editor section, yes? but I am not sure how that will help assign a value to var 58 based on which of var51-57 is the highest and then be able to read it in my event that gives the player their starting item?
Super sorry if i sound dumb, I'm very much still learning! If you could explain how this works so I can better learn that'd be amazing! Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/rpmxp-need-help-finding-largest-variable-out-of-7.158361/