SGS Stats and Yanfly Base Parameters

I am having some trouble getting these to work together.  When I use the calls that are given in the SGS script on how to add them into formulas, they don't work inside Yanfly's Base  Parameters script.  I get an error that states property of 'vit' is undefined.  I have defined the stats and can confirm that everything is entered in correctly, but for some reason as soon as I start the game, this error occurs.  If I remove the stats from Yanfly's script, the game boots up fine.  If I change how they are called it boots with no stats.  I am not sure if it is the way the plugin is written or if there is something else, but I changed to this script from another because it offered better updates to stats and allowed for equipment to properly calculate out changes in damage and other stats when swapping equipment.  Anyone who has solved this issue, any help is greatly appreciated.  I will post the debug console as soon as I am home or can remote in to pull the information.
Can you screenshot how you have your plugins layered?


It may be conflicting with another script.
Here are the plugins as listed.  I have included them as attachments.  It's a pretty big list of plugins.  I didn't have any issues until I switched.  I was using Bobstah's custom stats previously.

plugins 1.png

plugins 2.png
I have an overwhelming feeling that this is your problem.


I would usually have my CORE plugin above anything that uses it as a base for further plugins.
I've moved the SGS Stats script from the top to the bottom to the middle and it still gives me the same error.  The Yanfly scripts are in order per Yanfly's website.  I will attach the error along with the debug console.

debug console.png

Error.png
Hi and sorry there for the necrobump ; but this problem wasn't solved and I happened to have it too :distrust:

I *feel* like it's not a hard one, like it just needs a character or a word somewhere to fix it--


So I use SGS Stats and Yanfly's Base Parameter Controls plugins too, right? 🙂
Very basic stuff. In SGS Stats I just created the "pwr" parameter. By writing "pwr" in the list of new stats
basicshit.jpg


In Yanfly's base parameter controls, I just wanted to do a very basic test : someone's HP is equal to their power :|
basicshit.jpg

So I wrote for the HP formula : user.pwr


Of course I need to give a value to an unit's pwr, so I just give 60 pwr to my boi right here
Spoiler
basicshit.jpg

I boot up the game, and then like Forthright I encounter a similar "Cannot read property 'xxxxx' of undefined" error :/
And as such, my HP takes the value of 0 like if pwr didn't exist (well actually HP is 1 because I set the minimal to 1 in MHP Minimum)

What terms in MHP Formula would make this work, if that's not user.pwr ? (a.pwr doesn't work neither btw)

Spoiler
basicshit.jpg


IN BATTLE, THE STAT WORKS. If I make the ATTACK skill's formula into "a.pwr", it works fine and deal 60 dmg.


If someone had this issue and know how to fix it, I'm pretty sure it's going to be useful as many users mix Yanfly scripts with other scripts :V
-bumperino-
I started learning JS recently but I'm still not enough fluent enough to fix my issue 'v' halp please
Found a lazy, way to fix this for those having the issue.

First off, I noticed only MHP and MMP don't work. After analyzing the code I noticed MHP and MMP are generated at the beginning of the game, BEFORE the SGS stats exists.
From what I experienced, SGS stats start existing :
1) when you pick your first fight
2) if you equip or desequip an equipment
Both of these "refresh" your MHP/MMP and will apply the formula you wanted.

When you want to retrieve a SGS custom stat in Yanfly's Base formula, it doesn't matter if you use this/target/a/b/user. Works the same. this.sgsStat('pwr') and user.sgsStat('pwr') are the same.

Anyway tl;dr to fix it :
1) go to Yanfly Base Param Control toward the line ~679. See this line
Yanfly.Util.displayError(e, code, 'CUSTOM PARAM FORMULA ERROR');
add a // right before it
//Yanfly.Util.displayError(e, code, 'CUSTOM PARAM FORMULA ERROR');
This is done to prevent an error to pop-up in the console
2) At the very beginning of your game, do a very quick autorun event which equip or unequip something to each of your actors
Whenever you equip/unequip something to an actor, their stat gets "refreshed". So their HP/MP will get to the correct value
(Remember actors need to have the item to equip it lel. Give each of your actors a sword, equip it, and then desequip and take it from them. Boom HP/MP now is gucci)

Original thread: https://forums.rpgmakerweb.com/threads/sgs-stats-and-yanfly-base-parameters.64343/