MV Equip Window Stat Comparision Icons

Good morning, afternoon, evening.

I request your assistance once more.


07.07.2023_12.16.43_REC.png

Is it possible to code a snippet that shows an icon for lower and higher stat comparision instead of the traditional
arrow?

If possible it should be compatible with Yanfly's Equip Core but could also work with the default equip menu.

Similar to this, it could display an icon with an arrow up to show a stat getting raised, and another icon to show a stat getting lowered.

07.07.2023_12.17.55_REC.png



(function() {
var _Window_StatCompare_drawParamName = Window_StatCompare.prototype.drawParamName;
Window_StatCompare.prototype.drawParamName = function(item, x, y) {
_Window_StatCompare_drawParamName.call(this, item, x, y);
this.drawParamIcon(item, x, y);
};

Window_StatCompare.prototype.drawParamIcon = function(item, x, y) {
var currentValue = this._actor.param(item);
var newItem = this._tempActor ? this._tempActor.equips()[this._slotId] : null;
var newValue = newItem ? newItem.params[item] : currentValue;

var iconDown = 23; // Replace with the icon ID for lowered stats
var iconUp = 24; // Replace with the icon ID for raised stats

var iconId = 0;
if (currentValue < newValue) {
iconId = iconUp;
} else if (currentValue > newValue) {
iconId = iconDown;
}

if (iconId > 0) {
var iconWidth = Window_Base._iconWidth;
var iconHeight = Window_Base._iconHeight;
this.drawIcon(iconId, x + this.textWidth(' '), y + this.lineHeight() - iconHeight);
}
};
})();



I tried coding this myself but this gave me a type error

07.07.2023_12.28.49_REC.png


Any help is appreciated.
Based on YEP Equip Core (untested):
Spoiler: plugin code
JavaScript:
/*:
 * @target MV
 * @plugindesc Extends YEP_EquipCore - use +/0/- icons for stat compare on equip scene.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/159057/
 * @help Should load after YEP_EquipCore.
 * 
 * Free to use and/or modify for any project, no credit required.
 */
void (function() {
'use strict';

  // Check load order.
  if (!Imported || !Imported.YEP_EquipCore)
    throw new Error("This plugin should be loaded after YEP_EquipCore.");

  /** "Param increase" icon ID for compare arrow. */
  const ICON_UP = 24;
  /** "Param unchanged" icon ID for compare arrow. */
  const ICON_NOCHANGE = 0;
  /** "Param decrease" icon ID for compare arrow. */
  const ICON_DOWN = 23;

  /** Local var to carry param ID from `drawItem` to `drawRightArrow`. */
  let p = 0;

  // Patch - store param ID for reference in `drawRightArrow`.
  const _Window_StatCompare_drawItem = Window_StatCompare.prototype.drawItem;
  Window_StatCompare.prototype.drawItem = function(x, y, paramId) {
    p = paramId;
    _Window_StatCompare_drawItem.apply(this, arguments);
  };

  // Override - replace unicode arrow with system icon.
  Window_StatCompare.prototype.drawRightArrow = function(y) {
    const x = this.contents.width - this.textPadding() - this._paramValueWidth
            - this._arrowWidth - this._bonusValueWidth;
    if (this._tempActor)  // only draw if comparing
      switch (Math.sign(this._tempActor.param(p) - this._actor.param(p))) {
        case -1:
          this.drawIcon(ICON_DOWN, x, y);
          break;
        case 0:
          this.drawIcon(ICON_NOCHANGE, x, y);
          break;
        case 1:
          this.drawIcon(ICON_UP, x, y);
          break;
      }
  };

})();
Even if it works as intended with YEP Equip Core, it won't work with the core scripts due to several differences in the code. Also, this won't affect other scenes, e.g. the shop.
Please post code using the CODE tag, the </> in the edit bar. That maintains indentation and any content in brackets - what you have up there is rather hard to read.

1 - the structure of your drawParamName doesn't look right. If you call the original function and then the up/down icon, you're going to see that icon everywhere that parameter name is drawn, which is surely not what you want.

2 - why did you change the arguments passed into drawParamName? There's no point in aliasing a function if it breaks the existing function calls in the code. For that matter, your _Window_StatCompare_drawParamName.call will fail.

3 - what is this item that you're passing into the functions? Is it an actual reference to the item that's being equipped? Because then saying this._actor.param(item) doesn't make any sense. That expects a numeric value, not an item.
Thank you so much for this! If I have any trouble I'll let you know!

Original thread: https://forums.rpgmakerweb.com/threads/equip-window-stat-comparision-icons.159057/