[Yanfly Core / Shop Menu Core] Trying to limit Max Items by variable instead of static number

Yanfly Core: http://yanfly.moe/2015/10/09/yep-1-core-engine/

My game is crafting/resources/shop management type of game, and is currently using an ammunition-style arrangement for handling skills in battle using Yanfly Skill Cost plugin. For example, "Shoot Arrow" costs 1 Arrow.

Because it's also a game of resource management, I've implemented limits on Arrows. At first it was just 5 but then as the user progresses through the story, I felt they should be able to upgrade their "Quiver" in order to hold more Arrows (7, 10, etc.).

I tried setting the notetag to <Max Items: $gameVariables.value(83)> but that didn't do anything.

Then I found JS Items Max by @Engr. Adiktuzmiko which works perfectly!

Over time, I've found that I depend on this plugin immensely. More complicated than the Archer, there is a Mage within the party that uses a "hidden" resource based on elemental crystals. All of these crystals add up to their hidden resource, so it's important that I limit them based off a variable. A Fire Crystal looks like: <maxItems:$gameVariables.value(81) - $gameVariables.value(79) - $gameVariables.value(80)> (It subtracts Water Crystal and Storm Crystal from the hidden resource variable, which may be something like 5, so the Mage can't get a Fire Crystal if they already have 3 Water Crystals and 2 Storm Crystals).

Everything works UNTIL I open up Yanfly's Shop.

The shop is set up with multiple currencies so you can purchase Arrows from the Weaponsmith using Wood + Gold. This is extremely important to the gameplay.

Unfortunately, JS Items Max and Yanfly Shop Menu Core do not get along. No matter where I place the plugins in relation to each other, the game crashes immediately upon opening the shop. Attached is the error I receive.

Does anyone have a solution for this? Using both a Max Item Variable and Yanfly Shop Menu? I am open to new plugins, a revision to Yanfly's, or a revision to JS Items Max. I have posted on that thread but it's been a few days with no response so I thought I'd come to the forums with my own thread about it.

Thanks so much!
Just put a tiny edit in.

Try this and see if it works.
Code:
/*:

 * @plugindesc Allows you to set the max number of each item/armor/weapon using numbers or JS codes. Click help for HowToUse
 * @author Adiktuzmiko

 *@help To use just add this notetag to your items:
 <maxItems:value>
 value being any static number or a valid JS code

 Example:

 <maxItems:5> -> Sets that item to have a maximum amount of 5
 <maxItems:$gameVariables.value(1)> -> Sets the item to have a maximum amount
 equal to whatever the current value of Game Variable 001 is

 Note: It is important that the file name of this plugin is JSItemMax.js

 * @param General Item Max
 * @desc The general maximum amount for each item; you can use either a number or a valid JS code here
 * @default 99

*/

var JSItemMax = {};
JSItemMax.params = PluginManager.parameters('JSItemMax');
JSItemMax.generalItemMax = JSItemMax.params["General Item Max"];

Game_Party.prototype.maxItems = function(item) {
  if (!item) return 0; //It needs to return a number!
  if (item.meta.maxItems) {
    return eval(item.meta.maxItems);
  } else {
      return eval(JSItemMax.generalItemMax);
      }

};
@Maliki79 Thanks for giving it a go! It gives me a warning regarding the Core plugin now, attached, when I open a shop. I moved the plugin to the top and it doesn't do anything at all. When I move it below Core, it works by limiting the items, but it gives me the error when I open the shop.
Yikes... Guess something more intricate needs to be done.
I am still holding out hope a bit we can fix it, buuttt I might just need to give up and work around the variable max items. I need the More Currencies addon more, I think.
Try not to give up yet!
I made a little edit to the above.
Redownload it and let me know what happens.
Try not to give up yet!
I made a little edit to the above.
Redownload it and let me know what happens.
I think you did it!!

On my test map, new game, I opened the shop and no crash!

I am a little worried about posting this because I'm sure something terrible will happen later on, but - so far so good! Thank you so much!!

(I am also in New Jersey! Represent. You rock!)
NJ 4 lyfe! LoL
But dont worry. If you notice a problem just let me know.
Thanks for making a compatibility fix for it. 🙂
No worries. It was a minor edit.
😀

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-core-shop-menu-core-trying-to-limit-max-items-by-variable-instead-of-static-number.104850/