MV Yanfly Item Core - Check used inventory slots

Hi all,

Long time lurker, haven't posted much before.

I am using Yanfly's Item Core for one of my games to limit the overall amount of items a player can carry. However, the Item Core limit gets overwritten when an item is obtained via event, and you can have more than max items this way. This is on purpose to avoid the player losing potential important quest items.

However, my game contains a foraging element and so most items will actually be obtained via event, rendering the limit from the plugin useless. Therefore, I am hoping for someone to be able to point me at how to implement one of the two below solutions:

1. Help me figure out how to disable this part of the Item Core, so that obtaining an item always fails when the item limit is reached for that category; OR

2. Help me figure out the script call that returns either used or free inventory slots, so I can add a conditional branch to my events that only allows the player to pick up an item if there is a free slot in the inventory.

Example: set variable 5 = $gameParty.getInventorySpaceLeft(); if var 5 =0 the item can't be collected (except this script call I have written here doesn't work; I took it from someone else's abandoned item limit plugin that is sadly otherwise broken).

Any help or advice would be super appreciated. Thank you!

-SBB
I don't think YEP Item Core has ever offered inventory limits? You might be confusing it with the plugin's Max Items/Weapons/Armors parameters...as far as I know, those are just used to determine where independent item IDs start. [Edit: never mind, I confused them with the Starting ID parameter. 😴]

I think you can check total occupied inventory "slots" using Control Variables -> Script:

$gameParty.allItems().length
To specifically check only Items, Weapons, or Armors, replace allItems with items, weapons, or armors respectively.
I don't think YEP Item Core has ever offered inventory limits? You might be confusing it with the plugin's Max Items/Weapons/Armors parameters...as far as I know, those are just used to determine where independent item IDs start.
I didn't think so, either, but it does. Those are, in fact, inventory limits for the respective types of items.
1691706903723.png


As caethyril said, you can get the current number of items in the inventory with $gameParty.items().length
@ATT_Turan - oh, I see, I was confusing the Max etc params (limits independent items) with the Starting ID param. Oops. 😴
Thank you both! That script call has worked perfectly for what I'm trying to do. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-item-core-check-used-inventory-slots.160192/