Change item maximum ingame

Hey guy, 


My sugesstion is in the title.


I use yanfly core and item core, but there you can only make notetags. But i want to change the maximum amount for an item ingame via plugin or scriptcalls.


This would be awesome if someone can help 🙂
Christmas BUMP!
If those notetags accept call code setup instead of defined values, you can do this with just those scripts.. can you post a link to the script so that I can check if you can make it call code or not?


like instead of doing something like (not the correct tag ofc coz I havent seen the script)


<max 1> you make it <max $gameVariables(1)> so that it will set it's max to the value of Game Variable 001
I guess one question is are you talking about increasing the number of independent items or stackable items? If I remember correctly I had some issues trying to get independent items to properly increase the max you could carry.


and for the above idea, they MV version for getting a variable would be $gameVariables.value(1) 😉
I want to create an ammo system and if i upgrade the magazine than the maximum amount will increase. Also stackable items.

I use yanflys skill use item plugin and it will allows to swap the mp gauge to an item gauge. But the gauge always shows the maximum amount and the current amount.
If i have a colt with 6 bullets than it will shows the gauge 6/99. That looks wierd. Than i can tag the item with <Max Item: 6> for example. Than the gauge shows the 6/6.


But if upgrade the magazine it should be shows 8/8 for example. And for this i need to change the max amount via scriptcall or everthing else.


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



Yanfly item core:
http://yanfly.moe/2015/10/16/yep-11-item-core/


Yanfly Skill costs item:
http://yanfly.moe/2015/12/12/yep-43-skill-cost-items/
Right now it seems like the plugin only sets the maximum amount during initialization so even if it can take a code, it will only run during init and will not update during gameplay... 


it seems like it's easier to just make a new plugin that will allow you to have a dynamically run code as Item Max... that way it will also run independently of yanfly's plugins..


I have an idea (it's pretty easy to do) but I need to test it first when I get home and able to open MV 🙂  


EDIT: try to make a new js file in your js folder and add this code, then add it as a plugin in the plugin manager


var Game_Party.oldMaxItems = Game_Party.prototype.maxItems;

Game_Party.prototype.maxItems = function(item) {
var max = Game_Party.oldMaxItems(item)
if (item.note.match(/<(?:MAX ITEM):[ ](\d+)>/i)) {
return eval(RegExp.$1);}
else {
return max;}
};


then you can try using in your notetags for testing


<Max Item: $gameVariables(1)>


then see if the maximum of that item will vary depending on the value of Game Variables 001.


Take note though that the code I wrote is untested as of this writing.
Code:
[FONT=arial]I'm afraid the code does not work. It does not crasht, but it also does not limit the item :([/FONT]
I've been messing with this idea and I can get items limited with a variable, but it limits ALL items to this max value. I will keep trying ideas til I am out of them on how to limit specific IDs, but I'm running out quickly. >.<
Old reply:

Spoiler
that code actually has an error at line 1 which makes the game disable it during runtime, so the code doesn't even execute.


I'm trying to make it work, I already have a version which does run the code when you get items but somehow the eval doesn't want to evaluate $gameVariables(blahblah).. 

I've been messing with this idea and I can get items limited with a variable, but it limits ALL items to this max value

What's your code? maybe we can implement that idea into the per item basis if I can see it 🙂


here try this code



var oldMaxItems = Game_Party.prototype.maxItems;

Game_Party.prototype.maxItems = function(item) {
var max = oldMaxItems(item)
if (item.note.match(/<(?:MAX ITEM):[ ](\d+)>/i)) {
return eval(RegExp.$1);}
else {
return max;}
};




your notetag should be


<MAX ITEM:$gameVariables.value(x)>


x being the index of the variable you want it to base on


or you can also try this one (try the above one first)



Spoiler





var oldMaxItems = Game_Party.prototype.maxItems;

Game_Party.prototype.maxItems = function(item) {
var max = oldMaxItems(item)
if (item.meta.itemmax) {
return eval(item.meta.itemmax);}
else {
return max;}
};


but your notetag should be


<itemmax:$gameVariables.value(x)>


x being the index of the variable you want it to base on






EDIT: Here's a working JS file for you. Just download it as JSItemMax.js (make sure the file name is exactly that), import it into your plugins folder, add it in the plugin manager (preferably make sure its below everything else on the list), read the help thingy and start tagging.

Original thread: https://forums.rpgmakerweb.com/threads/change-item-maximum-ingame.72592/