Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,321
Reaction score
1,062
First Language
French
For instance, from item 05 to item 52?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,035
Reaction score
4,644
First Language
English
Primarily Uses
RMMZ
Code:
for (let i = 5; i <= 52; i++) { $gameParty.loseItem($dataItems[i], 99) }
 
Last edited:

Cormorant42

Veteran
Veteran
Joined
Sep 17, 2019
Messages
114
Reaction score
54
First Language
English
Primarily Uses
RMMV
Copy and paste this code into a "script" event:

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.
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,035
Reaction score
4,644
First Language
English
Primarily Uses
RMMZ
Copy and paste this code into a "script" event:

JavaScript:
(function() {
    let itemMax = $gameVariables.value(REPLACE_Y);
    for (itemMin = $gameVariables.value(REPLACE_X); itemMin <= itemMax; itemMin++) {
        if ($gameParty.hasItem(itemMin) == true) {
            $gameParty.loseItem($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.
 

Cormorant42

Veteran
Veteran
Joined
Sep 17, 2019
Messages
114
Reaction score
54
First Language
English
Primarily Uses
RMMV
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?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,035
Reaction score
4,644
First Language
English
Primarily Uses
RMMZ
I did the same when I saw yours; I'd forgotten loseItem was a thing. XD
 

Cormorant42

Veteran
Veteran
Joined
Sep 17, 2019
Messages
114
Reaction score
54
First Language
English
Primarily Uses
RMMV
Yeah, it's super handy. Especially whenever I jump back into rmmv after a couple months & have forgotten the functions and methods lol
 

DarkFrost

Villager
Member
Joined
Sep 8, 2013
Messages
29
Reaction score
11
First Language
English
Primarily Uses
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.
 

Latest Threads

Forum statistics

Threads
124,349
Messages
1,162,944
Members
163,147
Latest member
onbetme
Top