MZ Tips&Tricks Libra skill never displaying Absorbs?

As per the title. I'm trying to implement a modified version of the Libra skill (as seen in this link, although the version posted there does not work either). The modifications include checking for notetags to see for example if said enemy is a spider, moving some sections to the message's name box, making it work through an action sequence instead, and adding commas if there is more than one weakness, resist, immune or absorb. These all play out fine. However, with both my modifications and the original post in the link above, the message will always say the targeted enemy does not absorb any elements (defined by VisuStella's element/status core with the note tag Element Absorb: ID or name, I'm also using the majority of their other plugins although I don't think most of them have any effect on absorptions), while my test boss is definitely tagged with
JavaScript:
<Element Absorb: 4>
//alternatively
<Element Absorb: Shock>
Neither of these make any changes. Below are my modifications:

JavaScript:
 if ($target.isEnemy()) {
    const id = $target._enemyId;
    $gameSystem.registerDefeatedEnemy(id);
  }

  let whodis = $target.name() + '\\}';
  if ($target.meta.spider) { whodis += '\\c[0]\\i[0]\\i[1829] Arachnid'}
  whodis += '\\c[0]\\i[0]\\i[1827] ' + $target.hp;
  whodis += '/' + $target.mhp;
  whodis += '\\c[0]\\i[0]\\i[1818] ' + $target.mp;
  whodis += '/' + $target.mmp;

  $gameMessage.setSpeakerName(whodis);

  let text = '';
  text += ' \\>\\c[4]Power:\\c[0] ' + $target.atk;
  text += '\\i[0]\\c[4]Armor:\\c[0] ' + $target.def;
  text += '\\i[0]\\c[4]Healing:\\c[0] ' + $target.mat;
  text += '\\i[0]\\c[4]Fortune:\\c[0] ' + $target.mdf;
  text += '\\i[0]\\c[4]Speed:\\c[0] ' + $target.agi + '<br>';
  $gameMessage.add(text);
 
  let weakness = '';
  let resist = '';
  let immune = '';
  let absorb = '';
  let elements = $dataSystem.elements;
  let weaknessLength = 0;
  let absorbLength = 0;
  let immuneLength = 0;
  let resistLength = 0;

  for (let i = 1; i < elements.length; ++i) {
    const name = elements[i];
    const rate = $target.elementRate(i);
    if (rate > 1) {
      if (weaknessLength > 0) {
        weakness += ', ';
      }
      weakness += name;
      weaknessLength += 1;
    } else if (rate < 0) {
      if (absorbLength > 0) {
        absorb += ', ';
      }
      absorb += name + ' ';
      absorbLength += 1;
    } else if (rate === 0) {
      if (immuneLength > 0) {
        immune += ', ';
      }
      immune += name;
      immuneLength += 1;
    } else if (rate < 1) {
      if (resistLength > 0) {
        resist += ', ';
      }
      resist += name;
      resistLength += 1;
    }
  }
  console.log(absorb);
  if (weakness === '') weakness = 'Nothing';
  if (resist === '') resist = 'Nothing';
  if (immune === '') immune = 'Nothing';
  if (absorb === '') absorb = 'Nothing';
  weakness = '\\>\\c[4]Weak to:\\c[0] ' + weakness;
  resist = '\\i[0]\\c[4]Resists:\\c[0] ' + resist + '<br>';
  immune = ' \\>\\c[4]Immune to:\\c[0] ' + immune;
  absorb = '\\i[0]\\c[4]Absorbs:\\c[0] ' + absorb;
  text = weakness + resist + immune + absorb;
  $gameMessage.add(text);

Could anyone help me figure out what the issue is?

(edit: For clarity, the console.log always returns an empty string, and Absorb in the message window defaults to Nothing for some reason.)
Because you're talking about two different methods. In @Trihan's adaptation of the skill, absorption is indicated by having a negative element rate (which is presumably a setting in one of the VisuStella plugins).

Your absorption has nothing to do with the element rate, it's setting a notetag.

The problem with your method is that VisuStella surely parses those notetags and stores them in some kind of nicely accessible array on the enemy's database entry. But since we can't browse their obfuscated code, unless the documentation gives you a way to access that data, you're going to have to open up a Game_Enemy object in the console and search through it for the applicable field.
Both of the adaptations don't work, however, like I said. I did try Trihan's version in case I messed something up with mine, but the same problem appears. I managed to check the enemy's element rates through the console, and with or without the notetag, supposedly absorbed elements simply return 1 like a neutral element would, so I'm not sure how absorbs are handled.
Both of the adaptations don't work, however, like I said.
I don't see any "both adaptations" that you're talking about.

The code you have in your first post does exactly the same thing Trihan's does:
Code:
if (rate < 0)
    stuff about absorbs

That is clearly saying that you are getting your data on what's absorbed based on their element rate being less than 0, which is what I said in my previous post. It would have nothing to do with any notetags.

Your code isn't doing anything different from Trihan's except it's splitting the formatting into several lines of code instead of just one statement, and you're incrementing some absorbLength variable that doesn't appear to be actually used for anything.
By "adaptations" I meant Trihan's version of the skill like you said, and my edits to it;
the length variables are used to add commas in case there is more than one weakness, resist etc so that the text doesn't look strange when it's printed. Absorptions seemed to me like they were handled through VisuStella's note tags (I checked the plugin settings, and the only place mentioning it is related to the status menu, seen below), since there's no way to make element rates negative in-editor, so this is kind of strange to me 😴 The getAbsorbedElements bit seemed promising, but I cant seem to figure out how to utilize it (enemies don't have the element column stuff, I think)

JavaScript:
// Declare Constants
const lineHeight = this.lineHeight();
const actor = this._actor;
const padding = this.itemPadding();
const labelFmt = '\\C[16]%1: \\C[0]%2';
const traitType1 = DataManager.traitSetType('Element');
const traitSet1 = actor.traitSet('Element');
const traitType2 = DataManager.traitSetType('SubElement');
const traitSet2 = actor.traitSet('SubElement');
const traitHeight = (this.innerHeight / Math.max(Window_StatusData.traitCol1.length, Window_StatusData.traitCol2.length)) - lineHeight;
let x = 0;
let y = 0;
let width = this.innerWidth / 2;

// Draw Actor Graphic
//this.drawActorGraphic(0, width);

// Draw Element Trait Sets
if (traitType1.Visible || traitType2.Visible) {
    this.drawItemDarkRect(x, y, width, lineHeight, 2);
    this.drawItemDarkRect(width, y, width, lineHeight, 2);
    if (traitType1.Visible) {
        this.drawTextEx(labelFmt.format(traitType1.Label, traitSet1.Display), padding, y, width - padding * 2);
    }
    if (traitType2.Visible) {
        this.drawTextEx(labelFmt.format(traitType2.Label, traitSet2.Display), width + padding, y, width - padding * 2);
    }
    y += lineHeight;
    this.setDescriptionFontSizeToTraitSet();
    this.drawItemDarkRect(x, y, width, traitHeight);
    this.drawItemDarkRect(width, y, width, traitHeight);
    if (traitType1.Visible) {
        this.drawTextEx(traitSet1.Description, padding, y, width - padding * 2);
    }
    if (traitType2.Visible) {
        this.drawTextEx(traitSet2.Description, width + padding, y, width - padding * 2);
    }
    this.resetDescriptionFontSize();
    this.resetFontSettings();
    y += traitHeight;
}
const topY = y;

// Prepare Elemental Data
const elementCol1 = this.getElementIDsCol1();
const elementCol2 = this.getElementIDsCol2();
let columnData;
if (elementCol2.length > 0) {
    columnData = ['Resist','Resist','Bonus','Bonus'];
} else {
    columnData = ['Resist','Bonus'];
}
const dataRows = Math.max(elementCol1.length, elementCol2.length, 1);
const dataCols = columnData.length;

// Draw Elemental Data
this.drawItemDarkRect(width * 0, y, width, lineHeight, 2);
this.drawItemDarkRect(width * 1, y, width, lineHeight, 2);
this.changeTextColor(ColorManager.systemColor());
this.drawText(TextManager.statusMenuDmgReceive, width * 0, y, width, 'center');
this.drawText(TextManager.statusMenuDmgDealt, width * 1, y, width, 'center');
y += lineHeight;
this.setDescriptionFontSizeToTraitSet();
const smallLineHeight = this.textSizeEx(' ').height;

// Draw Elemental Table
for (let i = 0; i < dataRows; i++) {
    for (let j = 0; j < dataCols; j++) {
        // Draw Dark Rect
        const colWidth = this.innerWidth / dataCols;
        this.drawItemDarkRect(colWidth * j, y, colWidth, smallLineHeight);

        // Draw Element Name
        let elementID = elementCol1[i];
        if (dataCols === 4) {
            elementID = (j % 2 === 0) ? elementCol1[i] : elementCol2[i];
        }
        if (!elementID) continue;
        const name = $dataSystem.elements[elementID];
        this.drawTextEx(name, colWidth * (j + 1/3) + padding, y, colWidth*2/3);
        const type = columnData[j];

        // Draw Resistance Data
        this.resetFontSettings();
        let drawText = '';
        if (type === 'Resist') {
            const rate = actor.elementRate(elementID);
            const flippedRate = (rate - 1) * -1;
            this.changeTextColor(ColorManager.paramchangeTextColor(flippedRate));
            drawText = '%1%'.format(Math.round(flippedRate * 100));
            if (actor.getAbsorbedElements().includes(elementID)) {
                this.changeTextColor(ColorManager.powerUpColor());
                drawText = TextManager.statusMenuDmgAbsorb.format(Math.round(rate * 100));
            } else if (rate > 1) {
                drawText = '%1'.format(drawText);
            } else if (rate <= 1) {
                drawText = '+%1'.format(drawText);
            }

        // Draw Bonus Damage Data
        } else if (type === 'Bonus') {
            const dealtPlus = actor.getDealtElementPlus(elementID);
            const dealtRate = actor.getDealtElementRate(elementID);
            const dealtFlat = actor.getDealtElementFlat(elementID);
            const dealt = ((1 + dealtPlus) * dealtRate + dealtFlat) - 1;
            this.changeTextColor(ColorManager.paramchangeTextColor(dealt));
            drawText = '%1%'.format(Math.round(dealt * 100));
            if (dealt >= 0) drawText = '+%1'.format(drawText);
        }

        // Draw Value
        this.contents.drawText(drawText, colWidth * j, y, (colWidth/3) - padding, smallLineHeight, 'right');
    }
    y += smallLineHeight;
}

// Closing the Table
for (let j = 0; j < dataCols; j++) {
    const colWidth = this.innerWidth / dataCols;
    this.drawItemDarkRect(colWidth * j, y, colWidth, this.innerHeight - y);
}
1692573415235.png

As I've said before on many an occasion, "it doesn't work" gives an amount of information equal to having said absolutely nothing, especially since it demonstrably works as intended on my end. What's it doing that it shouldn't, or not doing that it should?
I did say in my original post (though edited and maybe a bit unclear, sorry) that Absorb will always default to displaying None or Nothing.
That's where the issue is: the code isn't recognizing any absorb note tags, so even if the enemy is supposed to be absorbing fire damage or something, the message will always say "absorb: none". 😅
Ahh. Yeah, that wasn't clear at all. XD Let me have a look.
Sometimes things sound clear to me when I write them out, but then turn out being the opposite when I check the replies 😅 My bad.
1692573881909.png

Boom.

Change the line

JavaScript:
} else if (rate < 0) {

to

JavaScript:
} else if (rate < 0 || target.getAbsorbedElements().includes(i)) {

This was an oversight on my part: YEP's plugins do absorption via element rate traits that go below 0, whereas VS seems to determine absorption by evaluating the notetags.
After changing my Element Absorb: Shock to Element Absorb: 4 (the name variant will display as a string with spacebars in it), it worked perfectly! Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/tips-tricks-libra-skill-never-displaying-absorbs.160462/