MZ (Re)creating a Rank system with modules

So I'm trying to restart a game from VX Ace in MZ, and one of the things I wanted to add was a simple Rank system using variables and a module. Problem is, I don't know how to make a module in MZ. Right now I've just got the variable.

1689543300731.png


I knew how to do it in VX Ace, though:

1689543419837.png


Can anybody help?
JavaScript doesn't have anything that functions exactly like Ruby's modules. That being said, I don't quite see how modules are related to your screenshots. Can you explain exactly what it is that you're trying to do? Just mapping the numerical value of the variable to a corresponding string?

And where are you trying to do this? In a plugin that you're writing? In an event?
I'm not too sure about that either, but you can turn variables into strings (e.g. set variable to script "insert string here") and then it should work? I've used the variable section in Visustella's menu plugin for this.
It's basically a plugin I'm working on. I'm adjusting the Gold window (Lyra is the currency) to include a Ranking system based on a variable.

So in RGSS3 the module looked like this:

Ruby:
  module R_Title
    TITLE = ["Copper", "Bronze", "Silver", "Gold", "Platinum", "Black"]
  end

and the code for the Rank in the Gold window looked like this:

Ruby:
  def reputation_variable
    R_Title::TITLE[$game_variables[21]]
  end

And I want to take that and add that to my MZ project

JavaScript:
var Rank = ["Copper", "Bronze", "Silver", "Gold", "Platinum", "Black"];

Window_Gold.prototype.rank = function() {
    return $gameVariables.value(21);
};

So how do I return the associated Rank instead of the value of the variable?
It's basically a plugin I'm working on. I'm adjusting the Gold window (Lyra is the currency) to include a Ranking system based on a variable.

So in RGSS3 the module looked like this:

Ruby:
  module R_Title
    TITLE = ["Copper", "Bronze", "Silver", "Gold", "Platinum", "Black"]
  end

and the code for the Rank in the Gold window looked like this:

Ruby:
  def reputation_variable
    R_Title::TITLE[$game_variables[21]]
  end

And I want to take that and add that to my MZ project

JavaScript:
var Rank = ["Copper", "Bronze", "Silver", "Gold", "Platinum", "Black"];

Window_Gold.prototype.rank = function() {
    return $gameVariables.value(21);
};

So how do I return the associated Rank instead of the value of the variable?
I see. You just gotta use the value of the variable as the index of the array, like so:
JavaScript:
var Rank = ["Copper", "Bronze", "Silver", "Gold", "Platinum", "Black"];

Window_Gold.prototype.rank = function() {
    return Rank[$gameVariables.value(21)];
};

In your Ruby code, the usage of a module is moreso an organizational thing, and not actually pertinent to the functionality that you were trying to achieve. But if you want to mimic the Ruby code as closely as possible, it would be something like this:

JavaScript:
const R_Title = {
    TITLE: ["Copper", "Bronze", "Silver", "Gold", "Platinum", "Black"]
};

Window_Gold.prototype.rank = function() {
    return R_Title.TITLE[$gameVariables.value(21)];
};
1689547705028.png


Okay, yes. THANK YOU. That is exactly all I needed.

Original thread: https://forums.rpgmakerweb.com/threads/re-creating-a-rank-system-with-modules.159393/