Looking for a way to limit inventory item quantity

Hello, I am working on a project (VX Ace) that require something very particular.

A )
I'd like to be able to manage 2 inventory.

B )
1st one would be limited to a number of items (example : max 200 items in the inventory not counting equipped ones)
2st one would not have limit and would be available only when a key item is in player inventory.
EDIT : active only when a game switch will be turned ON.

C )
The specific inventory related key item is not considered when validating if the 200 max
is reached.
EDIT : Will use a game switch instead.

D )
A main menu item for inventory management with 3 sub-menu items.
==> Replenish order config
==> Inventory
==> Replenish inventory

D-1 )
Replenish order config : easy way to configure a replenishing order of the 1st inventory.
Example :
==> 20 free space (if enough space) *non removable 1st element of the config*
==> 100 hp potions (if enough space and enough exists in the 2nd inventory)
==> 50 bombs (if enough space and enough exists in the 2nd inventory)
==> etc.

D-2 )
Inventory : easy way to move items from inventory 1 to inventory 2 (or 2 to 1)
without triggering the replenishing function

D-3 )
Replenish inventory : Refill inventory 1 following configuration
Replenish do not remove items from inventory 1 but follows the order which items have been configured
(20 free space (ok), 100 hp potions (enough space for 88 so 88 hp potions), 50 bombs (can't replenish, inventory maxed).

D-4 )
Additional trigger that would try replenishing the 1st inventory
==> Adding the key item to inventory

E )
Inventory 2 will be available only when holding a specific key item.
(Will be gained and lost following some events)

EDIT : Using a game switch that will be ON /OFF following some events.

F )
Limiting the purchase of items in shops to inventory 1 size when not holding the key item.
EDIT : when inventory 2 is not active.

***

Is there something out there which I could easily use as a base to be able to script that kind of feature ?

Thanks

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-a-way-to-limit-inventory-item-quantity.174028/