How to clear inventory by script?

watermark

Veteran
Veteran
Joined
Dec 25, 2012
Messages
613
Reaction score
545
First Language
English
Primarily Uses
RMMV
How can I quickly empty the party inventory?

I am working on a puzzle game where the player needs to reset his items (such as keys left over from a previous level) when he enters a new level, and removing them one by one using "Change Items" is terribly inefficient.

Thanks!
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
This as a script call will completely delete all items the party has.

Code:
$gameParty._items = {};
If you want to restore the items later, you have to save it to a variable first.

Code:
$gameVariables.setValue(7, $gameParty._items);
$gameParty._items = {};

// to restore the items
$gameParty._items = $gameVariables.value(7);
 

watermark

Veteran
Veteran
Joined
Dec 25, 2012
Messages
613
Reaction score
545
First Language
English
Primarily Uses
RMMV
@Aloe Guvner Thanks so much! This is very useful.

Is there a way to get rid of a specific block of items too? For example I want to remove just items 10-23 (the keys for example), but have the party keep some of the other stuff between levels.
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
Is there a way to get rid of a specific block of items too? For example I want to remove just items 10-23 (the keys for example), but have the party keep some of the other stuff between levels.
Code:
for (var i = 10; i <= 23; i++) {
  delete $gameParty._items[i];
}
or
Code:
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23].forEach(function(itemId) {
  delete $gameParty._items[itemId];
});
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,018
Messages
1,018,358
Members
137,803
Latest member
andrewcole
Top