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,037
Reaction score
4,650
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,037
Reaction score
4,650
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,037
Reaction score
4,650
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

Latest Posts

Latest Profile Posts

Signing divorce papers today. Still makes no sense to me that this is a step I need to take to get my hubby the help he needs and deserves :( Life is strange people and sometimes it throws you a curve ball you have no chance in hell of catching
Just laid down a sick nasty new post in the MagiCats! Infinite Sadness thread! Lemme give ya a big ol' hug for it.

bg6.jpg
MacAdams wrote on Frogboy's profile.
Hey is there an MZ set of D&D style plugins yet?
Wheel of Attacks.png

MORE GAMBLING THEMED ATTACKS!

I AM UNABLE TO STOP!
Is it ok to repost stuff that i've posted to threads in the status feed?
If so, here's art of Shiloh, the main protagonist of the game i'm making:20220807_181702.jpg
They are meant to be ambiguous in gender, like Frisk from Undertale or Gogo from FFVI. I haven't decided what their age will be yet. Any ideas?
Please comment what you think about the art and design!

Forum statistics

Threads
124,468
Messages
1,163,875
Members
163,293
Latest member
oat1991997
Top