Get the number of items, weapons and armor in inventory?

So basically, i want a event that checks how many of a item, weapon or armor you have and then i want it to give me that information into a variable and if it's possible i also want to have one variable that counts everything but i'm guessing it's probably inefficient or very hard to do so
To count a specific Item/Weapon/Armor:
  • Control Variables -> Game Data -> Item/Weapon/Armor
To count all Items, you can use Control Variables -> Script:

$gameParty.items().reduce(function(a, c) { return a + $gameParty.numItems(c); }, 0)
This basically just does the event command, except it adds together the counts for all Items in the party inventory.
  • To count Weapons, replace $gameParty.items() with $gameParty.weapons()
  • To count Armors, replace $gameParty.items() with $gameParty.armors()
  • To count everything, replace $gameParty.items() with $gameParty.allItems()
To count a specific Item/Weapon/Armor:
  • Control Variables -> Game Data -> Item/Weapon/Armor
To count all Items, you can use Control Variables -> Script:

$gameParty.items().reduce(function(a, c) { return a + $gameParty.numItems(c); }, 0)

This basically just does the event command, except it adds together the counts for all Items in the party inventory.
  • To count Weapons, replace $gameParty.items() with $gameParty.weapons()
  • To count Armors, replace $gameParty.items() with $gameParty.armors()
  • To count everything, replace $gameParty.items() with $gameParty.allItems()
This does indeed work exactly as i want it to and much easier than i thought it'd be. Thank you very much.
You're welcome! Happy RPG Making~

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/get-the-number-of-items-weapons-and-armor-in-inventory.152386/