MZ Found a script to replicate the "Libra"/Enemy Scan effect, but it isn't working properly.

Since I don't want to necropost, I found this thread the other day, which is about making a Libra effect work in RPG Maker MZ, based on Yanfly's MV Tips & Tricks: Libra script: https://forums.rpgmakerweb.com/index.php?threads/how-do-i-mv-to-mz-yanflys-libra.127350/

I added it exactly as it's written in that thread, but I'm having an issue with how things are displayed in the window that comes up when you use the skill. It's supposed to display two pages - the first page listing an enemy's stats, which seems to work fine, and a second page that lists off their weaknesses and such, which is where I'm having the problem.

1659807135592.png

^ The first page, which is fine. Actually not fine now that I look at it, because my game doesn't use the terms MAT or MDF. How can I get the script to display the terms I want it to? Which would be INT and SPR respectively.

1659807159489.png

^ The second page, which should display the weaknesses and such, but is instead listing out every single element if even one element is valid in each field.

1659807552215.png

^ This is what the enemy's database page says. As you can see, it should display that it is weak to Fire, resistant to Ice, immune to Lightning, and that it doesn't absorb anything. However, for the weakness, resistance and immunity fields in battle, it's showing every single element in the game.

I've tried both enabling and disabling the VisuStella SkillsStatesCore and ElementStatusCore, but neither of them seem to have any bearing on why this is happening. I am using the VisuStella Battle Core of course, and disabling it prevents the skill from displaying anything other than a failure message.

Also, here's the skill page in question:

1659807876422.png


So yeah... what's wrong and how do I fix it?
I've taken a look at the script you mentioned in the post and attempted to fix it.
As for how to change the name of stuff like "MAG", "MDF", etc. look into the sections which have color codes espace codes like this \c[14].
Although i've also 'fixed' that for you by changing them myself.

As for the reason why it wasn't working correctly(for anyone wondering) it was missing an 'i' the var name section, displaying the whole thing instead of what's needed.

Spoiler: Fixed Code
JavaScript:
<JS Post-Apply>

if (target.isEnemy()) {

var id = target._enemyId;





var text = target.name() + '\n';

text += '\\c[14]HP:\\c[0] ' + target.hp;

text += '/' + target.mhp;

text += '\\c[14] MP:\\c[0] ' + target.mp;

text += '/' + target.mmp;

text += '\\c[14] TP:\\c[0] ' + target.tp;

text += '\n';

text += '\\c[14]ATK:\\c[0] ' + target.atk;

text += '\\c[14] INT :\\c[0] ' + target.mat;

text += '\\c[14] AGI:\\c[0] ' + target.agi;

text += '\n';

text += '\\c[14]DEF:\\c[0] ' + target.def;

text += '\\c[14] SPR:\\c[0] ' + target.mdf;

text += '\\c[14] LUK:\\c[0] ' + target.luk;

$gameMessage.add(text);



var weakness = '';

var resist = '';

var immune = '';

var absorb = '';

var elements = $dataSystem.elements;

for (var i = 1; i < elements.length; ++i) {

var name = elements[i];

var rate = target.elementRate(i);

if (rate > 1) {

weakness += name + ' ';

} else if (rate < 0) {

absorb += name + ' ';

} else if (rate === 0) {

immune += name + ' ';

} else if (rate < 1) {

resist += name + ' ';

}

}

if (weakness === '') weakness = 'None';

if (resist === '') resist = 'None';

if (immune === '') immune = 'None';

if (absorb === '') absorb = 'None';

weakness = '\\c[14]Weakness:\\c[0] ' + weakness + '\n';

resist = '\\c[14]Resist:\\c[0] ' + resist + '\n';

immune = '\\c[14]Immune:\\c[0] ' + immune + '\n';

absorb = '\\c[14]Absorb:\\c[0] ' + absorb;

text = weakness + resist + immune + absorb;

$gameMessage.add(text);

}

</JS Post-Apply>
I've taken a look at the script you've mentioned in your post and attempted to fix it.
As for how to change the name of stuff like "MAG", "MDF", etc look into the sections which have color codes espace codes like this \c[14].
Although i've also 'fixed' that for you and changed them myself.

As for the reason why it wasn't working correctly(for anyone wondering) it was missing an on the var name section, display the whole thing instead of what's needed.

Spoiler: Fixed Code
JavaScript:
<JS Post-Apply>

if (target.isEnemy()) {

var id = target._enemyId;





var text = target.name() + '\n';

text += '\\c[14]HP:\\c[0] ' + target.hp;

text += '/' + target.mhp;

text += '\\c[14] MP:\\c[0] ' + target.mp;

text += '/' + target.mmp;

text += '\\c[14] TP:\\c[0] ' + target.tp;

text += '\n';

text += '\\c[14]ATK:\\c[0] ' + target.atk;

text += '\\c[14] INT :\\c[0] ' + target.mat;

text += '\\c[14] AGI:\\c[0] ' + target.agi;

text += '\n';

text += '\\c[14]DEF:\\c[0] ' + target.def;

text += '\\c[14] SPR:\\c[0] ' + target.mdf;

text += '\\c[14] LUK:\\c[0] ' + target.luk;

$gameMessage.add(text);



var weakness = '';

var resist = '';

var immune = '';

var absorb = '';

var elements = $dataSystem.elements;

for (var i = 1; i < elements.length; ++i) {

var name = elements[i];

var rate = target.elementRate(i);

if (rate > 1) {

weakness += name + ' ';

} else if (rate < 0) {

absorb += name + ' ';

} else if (rate === 0) {

immune += name + ' ';

} else if (rate < 1) {

resist += name + ' ';

}

}

if (weakness === '') weakness = 'None';

if (resist === '') resist = 'None';

if (immune === '') immune = 'None';

if (absorb === '') absorb = 'None';

weakness = '\\c[14]Weakness:\\c[0] ' + weakness + '\n';

resist = '\\c[14]Resist:\\c[0] ' + resist + '\n';

immune = '\\c[14]Immune:\\c[0] ' + immune + '\n';

absorb = '\\c[14]Absorb:\\c[0] ' + absorb;

text = weakness + resist + immune + absorb;

$gameMessage.add(text);

}

</JS Post-Apply>

It works now! Thanks! 😀

1659815506374.png
I've got a problem where the second message showing weaknesses isn't displaying at all for some reason. It shows the first one, that being stats, but then when I hit space to go the next one, it just closes and doesn't display the weaknesses. Yes, my enemies have weaknesses.

@DeathKnight, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.


Please make a new thread instead.

Original thread: https://forums.rpgmakerweb.com/threads/found-a-script-to-replicate-the-libra-enemy-scan-effect-but-it-isnt-working-properly.150165/