MZ how to get certain data

Hey there sages and sagets.... um yeah I'm wondering if anyone knows how to access data of the items that the player possesses and the ones that are in the database along with its information? This is kind of hard and as I've been trying for a while now (fruitlessly) reading through code etc. oh, its through js might I add. and while events and such are somewhat easier it doesn't quite give me the edge I need. I'm making a custom menu screen so (key items, equipment's and consumables) are the ones I'm particularly interested in accessing and prolly editing. Many thanks in advance k? oh I broke my leg recently so I have a bit of time now so I'm hoping I can finish my current project while I'm recouping y-know? 😮‍💨

im not a sociopath i swear....
Search for keywords in this spreadsheet and you'll find much of what you might be looking for 🙂
For info on the properties defined for Items, Weapons, and Armors, you can either check the respective JSON file in a project's data subfolder or the Database sheet of this reference:
Database data for Items, Weapons, and Armors are stored in global arrays:
  • Items: $dataItems;
  • Weapons: $dataWeapons;
  • Armors: $dataArmors.
These are indexed by ID. E.g. $dataArmors[5] is the database object representing Armor ID 5. Index 0 is null for all database arrays.

Inventory data is stored by item type:
  • Items: $gameParty._items;
  • Weapons: $gameParty._weapons;
  • Armors: $gameParty._armors.
These are key-value pairs: the key is the ID, the value is the quantity. E.g. $gameParty._weapons[8] gets the quantity of Weapon 8 in the party inventory, or undefined if there are none.
You can retrieve the player's current items using:
JavaScript:
let items = $gameParty.items();
let weapons = $gameParty.weapons();
let armors = $gameParty.armors();

let equipItems = $gameParty.equipItems(); // contains weapons and armors.

let allItems = $gameParty.allItems(); // contains items, weapons, and armors.
These are all arrays.

Note that the inventory DOES NOT contain items that are currently equipped. For example, if the player finds a helmet, that helmet will be in the inventory. If the player equips that helmet, it will be removed from the inventory.

You can retrieve the party's equipped items like this:
JavaScript:
let equippedItems = $gameParty.members().flatMap(member => member.equips()).filter(equip => equip !== null);

// To combine it with allItems:
let allItemsAndEquipped = allItems.concat(equippedItems);

In order to find out how many of a specific item the player has:
JavaScript:
let item = $gameParty.allItems()[0];
let itemCount = $gameParty.numItems(item);
In this example, itemCount will be a number representing how many of the first item (item with index 0) the player owns, whatever that "first item" may be.

Again, this does not include equipped items. To include those:
JavaScript:
let equippedItemCount = $gameParty.members().flatMap(member => member.equips()).filter(equip => equip === item).length;
let itemCountAndEquipped = itemCount + equippedItemCount;
As for retrieving an item's data, you can take a look at the Armors.json, Items.json, and Weapons.json files to learn about their structure.

The structure of an item:
JavaScript:
item.animationId        // number
item.consumable         // boolean

item.damage.critical    // boolean
item.damage.elementId   // number
item.damage.formula     // string
item.damage.type        // number
item.damage.variance    // number

item.description        // string

item.effects[i].code    // number
item.effects[i].dataId  // number
item.effects[i].value1  // number
item.effects[i].value2  // number

item.hitType            // number
item.iconIndex          // number
item.id                 // number
item.itypeId            // number

item.meta               // notetags

item.name               // string
item.note               // string
item.occasion           // number
item.price              // number
item.repeats            // number
item.scope              // number
item.speed              // number
item.successRate        // number
item.tpGain             // number

The structure of a weapon:
JavaScript:
weapon.animationId      // number
weapon.description      // string
weapon.etypeId          // number
weapon.iconIndex        // number
weapon.id               // number

weapon.meta             // notetags

weapon.name             // string
weapon.note             // string
weapon.params           // array of numbers of length 8
weapon.price            // number

weapon.traits[i].code   // number
weapon.traits[i].dataId // number
weapon.traits[i].value  // number

weapon.wtypeId          // number

The structure of an armor:
JavaScript:
armor.atypeId           // number
armor.description       // string
armor.etypeId           // number
armor.iconIndex         // number
armor.id                // number

armor.meta              // notetags

armor.name              // string
armor.note              // string
armor.params            // array of numbers of length 8
armor.price             // number

armor.traits[i].code    // number
armor.traits[i].dataId  // number
armor.traits[i].value   // number

The structure of meta depends on what you put in the "Note" for the item. For example, if you put <tag1:13>, then you'd have item.meta.tag1 of type string with the value "13". And if you have <tag1:13><tag2:hello>, you'd have item.meta.tag1 and item.meta.tag2 of type string with the values "13" and "hello" respectively. You can also put notetags without value, like <tagWithoutValue>, which will give you item.meta.tagWithoutValue of type boolean with value true.
Search for keywords in this spreadsheet and you'll find much of what you might be looking for 🙂
ooo interesting i didnt know this existed! this wil def be used a-LOT! thanks~

For info on the properties defined for Items, Weapons, and Armors, you can either check the respective JSON file in a project's data subfolder or the Database sheet of this reference:
Database data for Items, Weapons, and Armors are stored in global arrays:
  • Items: $dataItems;
  • Weapons: $dataWeapons;
  • Armors: $dataArmors.
These are indexed by ID. E.g. $dataArmors[5] is the database object representing Armor ID 5. Index 0 is null for all database arrays.

Inventory data is stored by item type:
  • Items: $gameParty._items;
  • Weapons: $gameParty._weapons;
  • Armors: $gameParty._armors.
These are key-value pairs: the key is the ID, the value is the quantity. E.g. $gameParty._weapons[8] gets the quantity of Weapon 8 in the party inventory, or undefined if there are none.

ohhh wow thanks! lol i thought it would be simple but wow this is so much better than i could have hoped! i'll def post results after testing~

You can retrieve the player's current items using:
JavaScript:
let items = $gameParty.items();
let weapons = $gameParty.weapons();
let armors = $gameParty.armors();

let equipItems = $gameParty.equipItems(); // contains weapons and armors.

let allItems = $gameParty.allItems(); // contains items, weapons, and armors.
These are all arrays.

Note that the inventory DOES NOT contain items that are currently equipped. For example, if the player finds a helmet, that helmet will be in the inventory. If the player equips that helmet, it will be removed from the inventory.

You can retrieve the party's equipped items like this:
JavaScript:
let equippedItems = $gameParty.members().flatMap(member => member.equips()).filter(equip => equip !== null);

// To combine it with allItems:
let allItemsAndEquipped = allItems.concat(equippedItems);

In order to find out how many of a specific item the player has:
JavaScript:
let item = $gameParty.allItems()[0];
let itemCount = $gameParty.numItems(item);
In this example, itemCount will be a number representing how many of the first item (item with index 0) the player owns, whatever that "first item" may be.

Again, this does not include equipped items. To include those:
JavaScript:
let equippedItemCount = $gameParty.members().flatMap(member => member.equips()).filter(equip => equip === item).length;
let itemCountAndEquipped = itemCount + equippedItemCount;
As for retrieving an item's data, you can take a look at the Armors.json, Items.json, and Weapons.json files to learn about their structure.

The structure of an item:
JavaScript:
item.animationId        // number
item.consumable         // boolean

item.damage.critical    // boolean
item.damage.elementId   // number
item.damage.formula     // string
item.damage.type        // number
item.damage.variance    // number

item.description        // string

item.effects[i].code    // number
item.effects[i].dataId  // number
item.effects[i].value1  // number
item.effects[i].value2  // number

item.hitType            // number
item.iconIndex          // number
item.id                 // number
item.itypeId            // number

item.meta               // notetags

item.name               // string
item.note               // string
item.occasion           // number
item.price              // number
item.repeats            // number
item.scope              // number
item.speed              // number
item.successRate        // number
item.tpGain             // number

The structure of a weapon:
JavaScript:
weapon.animationId      // number
weapon.description      // string
weapon.etypeId          // number
weapon.iconIndex        // number
weapon.id               // number

weapon.meta             // notetags

weapon.name             // string
weapon.note             // string
weapon.params           // array of numbers of length 8
weapon.price            // number

weapon.traits[i].code   // number
weapon.traits[i].dataId // number
weapon.traits[i].value  // number

weapon.wtypeId          // number

The structure of an armor:
JavaScript:
armor.atypeId           // number
armor.description       // string
armor.etypeId           // number
armor.iconIndex         // number
armor.id                // number

armor.meta              // notetags

armor.name              // string
armor.note              // string
armor.params            // array of numbers of length 8
armor.price             // number

armor.traits[i].code    // number
armor.traits[i].dataId  // number
armor.traits[i].value   // number

The structure of meta depends on what you put in the "Note" for the item. For example, if you put <tag1:13>, then you'd have item.meta.tag1 of type string with the value "13". And if you have <tag1:13><tag2:hello>, you'd have item.meta.tag1 and item.meta.tag2 of type string with the values "13" and "hello" respectively. You can also put notetags without value, like <tagWithoutValue>, which will give you item.meta.tagWithoutValue of type boolean with value true.


woooow this is, a lot! thanks! you rock my dude!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-get-certain-data.147323/