how do i put the amount of items in one of the inventory's categories into a variable

there are four categories within the inventory, right? items, weapons, armor and key items
i want to know how to grab the number of items in one of those categories, and then put that number into a variable
Why don't you use the editor command "Control Variables"? If you select "Game Data", then click where it says "Map ID", it brings up a new page. The first 3 available choices are "Item", "Weapon" and "Armor". If you select one of them, click on the field to its to select which item, weapon or piece of armour you want to know the number that the party has. Key items are included with the ordinary items.

That post will show you how to filter the key items and count either items or key items.

Then for weapons and armors...LOL...it works if you modify the script there (take out the filter part) and change items to weapons or armor, so:
$gameParty.weapons().reduce(function(total, element){return total + $gameParty._weapons[element.id]},0)
$gameParty.armors().reduce(function(total, element){return total + $gameParty._armors[element.id]},0)

Or you can run for loop $gameParty.numItems(item), like (change the max value depending on your database):
let weaponNumb = 0
for (let i=0; i<100; i++) {
weaponNumb += $gameParty.numItems($dataWeapons[i]);
}
$gameVariables.setValue(100, weaponNumb)
this is basic I found on the rpg_manager
get by using
let gpI = $gameParty.allItems();
and check every array inside.. if there is key eTypeid.. there is posible weapon, armor etc
if there consumable.. perhaps is item
* can you give more detail on your request

That post will show you how to filter the key items and count either items or key items.
this link and the rest of your post is exactly what i was looking for, thank you
Another approach you can use is Object.values() which will give you an array of each quantity and reduce() in one line so you don't have to reference $gameParty twice:
JavaScript:
◆Control Variables:#0001 Items = Object.values($gameParty._items).reduce((a, b) => a + b, 0)
◆Control Variables:#0002 Weapons = Object.values($gameParty._weapons).reduce((a, b) => a + b, 0)
◆Control Variables:#0003 Armors = Object.values($gameParty._armors).reduce((a, b) => a + b, 0)

Should you need to separate the items from key items, the above method works (here is the arrow function version for key items):
JavaScript:
$gameParty.items().filter(x => x.itypeId === 2).reduce((a, b) => a + $gameParty._items[b.id], 0)

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-put-the-amount-of-items-in-one-of-the-inventorys-categories-into-a-variable.168925/