MZ Setting item/weapon/armor count to arrays through Javascript

So, I'm trying to set the item count of all items into an array. Unfortunately, there tend to be tons of different items, so I created an array in a variable to store the item counts in.

Now, I realize you can do this by setting a different variable to a different item's count and then adding the variable's value to the array. However, halfway through I realized this process would be long and painful, so I tried creating a different way to set the values.

The latest iteration of code I've gotten is:
var itemDummy = 7;
var itemCount;
$gameVariables.setValue(11, []);
while (itemDummy < 15) {
itemCount = $gameParty.numItems(itemDummy, false);
$gameVariables.value(11).push(itemCount);
itemDummy++;
}

This, like all my other attempts, only results in the array being created but without any values being set, despite my having items. I suspect it's the itemCount code that's the problem, but I don't know what else to do. Can anyone help?
So, I'm trying to set the item count of all items into an array.

Now, I realize you can do this by setting a different variable to a different item's count and then adding the variable's value to the array. However, halfway through I realized this process would be long and painful, so I tried creating a different way to set the values.

The latest iteration of code I've gotten is:
var itemDummy = 7;
var itemCount;
$gameVariables.setValue(11, []);
while (itemDummy < 15) {
itemCount = $gameParty.numItems(itemDummy, false);
$gameVariables.value(11).push(itemCount);
itemDummy++;
}

This, like all my other attempts, only results in the array being created but without any values being set, despite my having items. I suspect it's the itemCount code that's the problem, but I don't know what else to do. Can anyone help?
I'm just a little confused at what your attempting?
You want how many of 1 particular item stored into a variable?
Or the total items the player has? (just items or weapons/armors too)
I'm just a little confused at what your attempting?
You want how many of 1 particular item stored into a variable?
Or the total items the player has? (just items or weapons/armors too)
Sorry about that. I want to get the item count of every item the player has, including weapons/armor (not equipped), and store it into arrays. This is for easy access to the number of items the player has through one variable. This code is for the items, as I haven't written the ones for weapons and armor, considering it would be mostly the same.
Sorry about that. I want to get the item count of every item the player has, including weapons/armor (not equipped), and store it into arrays. This is for easy access to the number of items the player has through one variable. This code is for the items, as I haven't written the ones for weapons and armor, considering it would be mostly the same.
Oh no prob. Tada! I wrote a plugin for this 😉
CTB_PartyItemCount: Click Here to Download

Basically wrote a new function for the Game_Party object ☺️
Spoiler: getTotalItemCount function of Game_Party object
Game_Party.prototype.getTotalItemCount = function(noEquipment) {var x = 0; this.allItems().forEach(
function(v){
if (v.itypeId){var data = $dataItems;}else if (v.etypeId && !noEquipment){var data = (v.etypeId <= 1) ? $dataWeapons : $dataArmors;}
if (data){x = x + this.numItems(data[v.id]);}
}, this);
return x;
};

With that you can now easily use a script call to retrieve the total number of items.
Script call:
$gameParty.getTotalItemCount(optional: noEquipment)

Examples:
$gameParty.getTotalItemCount() // Will return count of all including equipment
$gameParty.getTotalItemCount(true) // Will return count of all NOT including equipment

Spoiler: Event Setup Screenshot
1598104004259.png

Using that plugin I made you can then set a variable to the total count using
Code:
$gameParty.getTotalItemCount()
1598104169155.png
Spoiler
1598104236666.png
Oh no prob. Tada! I wrote a plugin for this 😉
CTB_PartyItemCount: Click Here to Download

With that you can now easily use a script call to retrieve the total number of items.
Script call:
$gameParty.getTotalItemCount(optional: noEquipment)

Examples:
$gameParty.getTotalItemCount() // Will return count of all including equipment
$gameParty.getTotalItemCount(true) // Will return count of all NOT including equipment

Spoiler: Event Setup Screenshot

Using that plugin I made you can then set a variable to the total count using
Code:
$gameParty.getTotalItemCount()
View attachment 156453
Sorry, but this isn't what I was looking for, I'm sorry for being confusing about wording again. When I said the item count of every item, I meant item count of every individual item to keep an individual track of items for inventory swapping. I'm making a game using only default assets and want to stretch the system to its limits so I'm trying to find a vanilla solution. Once again, sorry for the confusion. 🙁
When I said the item count of every item, I meant item count of every individual item to keep an individual track of items for inventory swapping.

Oh ok no prob. Like this?

v1.10: Click here to Download

Spoiler: Script Calls
Code:
$gameParty.getTotalItemCount(optional: noEquipment)
$gameParty.getItemCountOfEach(optional: noEquipment)
Spoiler: Examples
Code:
$gameParty.getTotalItemCount() // Will return count of all including equipment
$gameParty.getTotalItemCount(true) // Will return count of all NOT including equipment
$gameParty.getItemCountOfEach() // Will return an array of objects that hold data for each item
$gameParty.getItemCountOfEach(true) // Will return an array of objects that hold data for each item NOT including equipment

Code:
$gameParty.getItemCountOfEach()
1598107878285.png

Will return an array of objects that hold data for each item:
1598105731119.png
Oh ok no prob. Like this?

v1.10: Click here to Download

Spoiler: Script Calls
Code:
$gameParty.getTotalItemCount(optional: noEquipment)
$gameParty.getItemCountOfEach(optional: noEquipment)
Spoiler: Examples
Code:
$gameParty.getTotalItemCount() // Will return count of all including equipment
$gameParty.getTotalItemCount(true) // Will return count of all NOT including equipment
$gameParty.getItemCountOfEach() // Will return an array of objects that hold data for each item
$gameParty.getItemCountOfEach(true) // Will return an array of objects that hold data for each item NOT including equipment

Code:
$gameParty.getItemCountOfEach()
View attachment 156487
Will return an array of objects that hold data for each item:
View attachment 156465
This is great, and I'm really sorry to say this, but I'm looking for a solution that's in the base software already. I want to push the limits of RPG Maker without using plugins, so I want to make this without any plugins whatsoever. Again, I'm really sorry, but this plugin will be kept in mind in case I ever decide to do this crazy thing again to save myself the headache.

Original thread: https://forums.rpgmakerweb.com/threads/setting-item-weapon-armor-count-to-arrays-through-javascript.125707/