For instance, from item 05 to item 52?
How to remove 99 of a range of items?
Javascript/Plugin Support
Code:
for (let i = 5; i <= 52; i++) { $gameParty.loseItem($dataItems[i], 99) }
Copy and paste this code into a "script" event:
Change "REPLACE_Y" to the ID of a game variable that will contain the ID of the last item you want to remove. Change "REPLACE_X" to the ID of a game variable that will contain the ID of the first item you want to remove.
In other words, you'd want game variable X to have a value of 5 and game variable Y to have a value of 52, and then you'd put the variable IDs of variable X and Y into the script above.
The reason for this is so you can change the amount of items you want to remove on the fly by changing variable X and variable Y.
JavaScript:
(function() {
let itemMax = $gameVariables.value(REPLACE_Y);
for (itemMin = $gameVariables.value(REPLACE_X); itemMin <= itemMax; itemMin++) {
$gameParty.gainItem($dataItems[itemMin], -99);
};
}) ();
Change "REPLACE_Y" to the ID of a game variable that will contain the ID of the last item you want to remove. Change "REPLACE_X" to the ID of a game variable that will contain the ID of the first item you want to remove.
In other words, you'd want game variable X to have a value of 5 and game variable Y to have a value of 52, and then you'd put the variable IDs of variable X and Y into the script above.
The reason for this is so you can change the amount of items you want to remove on the fly by changing variable X and variable Y.
The hasItem check is redundant because gainItem (which loseItem is a wrapper for) already checks the number of the item the party has.
Thanks, didn't know that! (i had just checked archaeia's master script call list for how to remove items.) I'll update the code, i guess?
I did the same when I saw yours; I'd forgotten loseItem was a thing. XD
Yeah, it's super handy. Especially whenever I jump back into rmmv after a couple months & have forgotten the functions and methods lol
Worked like a charm. Thank you so much.
I used a Yanfly core plugin to alter the item ranges. Some in my game can be as low as 3 max quantity, and other items can be held up to a quantity of 255.
This also allowed me to edit other limits too, such as stats, levels, and gold.
This also allowed me to edit other limits too, such as stats, levels, and gold.
Original thread: https://forums.rpgmakerweb.com/threads/how-to-remove-99-of-a-range-of-items.124363/