MZ Assistance figuring out specific help window text in equip screen.

Hi everyone, I'm back with another question lol.

My idea is when a character has nothing equipped in a slot, the help window shows text describing that slot, ie. "Main Hand", "Off Hand", "Head", "Body", "Accessory". Once an item is equipped, the help text shows that item's description as it normally does.

I'll share what I've got so far and I know it's wrong and that I'm missing some js concepts. With that, help would be appreciated. I think right now when I look at it I get a bit overwhelmed and have a hard time keeping track of what I'm doing. I'm sure this could be done much more streamlined using arrays, but piecing that all together is a bit out of my reach.

I thought using the actor ID would be the way to cycle through the current party members, but index might be better? So below is what I've got in between thoughts. Definitely a WIP.

Again, thanks for any and all help!

Code:
    Scene_Equip.prototype.update = function (index) {
        Scene_MenuBase.prototype.update.call(this);
        const actorIndex = this._actor.index();
        for (let i = 0; i < actorIndex; i++) {
        const actor_id = $gameParty.battleMembers()[i].actorId();
        const noItem0 = $gameParty.battleMembers()[i].equips()[0] == null;
        const noItem1 = $gameParty.battleMembers()[i].equips()[1] == null;
        const noItem2 = $gameParty.battleMembers()[i].equips()[2] == null;
        const noItem3 = $gameParty.battleMembers()[i].equips()[3] == null;
        const noItem4 = $gameParty.battleMembers()[i].equips()[4] == null;
        if (this._slotWindow) {
            if (this._slotWindow.active) {
                if (this._slotWindow._index == 0 && noItem0) {
                    this._helpWindow.setText('Main hand');
                } else if (this._slotWindow._index == 1 && noItem1) {
                    this._helpWindow.setText('right hand');
                } else if (this._slotWindow._index == 2 && noItem2) {
                    this._helpWindow.setText('your hand');
                } else if (this._slotWindow._index == 3 && noItem3) {
                    this._helpWindow.setText('my hand');
                } else if (this._slotWindow._index == 4 && noItem4) {
                    this._helpWindow.setText('their hand');
                }
            }
        }
    }
    };

EDIT: I got some helpful assistance yesterday which makes me think that something like this might be the way to get started. I'm working on it still.

Code:
Scene_Equip.prototype.update = function (index) {
        Scene_MenuBase.prototype.update.call(this);
        const item = this._actor.equips()[index];
        const helpEquipSlots = ['Main hand.', 'Off hand.', 'Head', 'Body.', 'Accessory.'];
        if (!item) {
            this._helpWindow.setText(helpEquipSlots[this._slotWindow._index]);
        }
    };

So far that writes the helpEquipSlots according to their index in the help window regardless if there's something equipped or not.
Typically a game window handles its own help text (updateHelp). So you'd just add some code to set the text to a slot-appropriate string when there's no item in that slot, e.g. (untested):
Spoiler: plugin code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Empty equip slot descriptions.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/174781/
 * @help Free to use and/or modify for any project, no credit required.
 */
;void (() => {

  /**
   * @param {number} slotId Reference slot ID.
   * @returns {string} "Empty" help text for given slot ID.
   */
  const slotText = function(slotId) {
    return ["Main hand", "Off hand", "Head", "Body", "Accessory"][slotId] ?? "";
  };

  // Patch - apply empty help text when appropriate.
  const alias = Window_EquipSlot.prototype.updateHelp;
  Window_EquipSlot.prototype.updateHelp = function() {
    alias.apply(this, arguments);
    if (!this.item())
      this._helpWindow.setText(slotText(this.index()));
  };

})();
Ah, perfect! That's quite the difference approach than what I've been doing. I'll need to look into how some of that coding works to get a good understanding of it. When I was using MV I found a helpful script that managed the help window through Scenes, so I've just followed that as I went along.

Thanks for the assistance @caethyril !
You're welcome! 👋

Generally, the object handling the interaction (in this case, the equip slot window) is the one that should handle its responses (e.g. updating help text). When the scene creates the slot window, it assigns the help window to it:
JavaScript:
Scene_Equip.prototype.createSlotWindow = function() {
    const rect = this.slotWindowRect();
    this._slotWindow = new Window_EquipSlot(rect);
    this._slotWindow.setHelpWindow(this._helpWindow);
That allows the slot window to communicate directly with the help window~

Original thread: https://forums.rpgmakerweb.com/threads/assistance-figuring-out-specific-help-window-text-in-equip-screen.174781/