Checking for different types of items in inventory

Hello, I am trying to check different items in the inventory for a conditional branch, my logic is something like this:


"If party inventory has 1 or more of item A, 2 or more of item B, and 3 or more of item C, then....else...."


How do I properly write this out using a script? Thanks!
You will need to place the inventory items as a variable and then use conditional branches to check them. Like this:


 
I7fbpdF.jpg



I use VX Ace, but from the screenshots I've seen, MV should basically be the same just different terminology.
Hello, I am trying to check different items in the inventory for a conditional branch, my logic is something like this:


"If party inventory has 1 or more of item A, 2 or more of item B, and 3 or more of item C, then....else...."


How do I properly write this out using a script? Thanks!



General syntax for checking if party has an item (ignoring whether it's equipped to an actor or not)


$gameParty.hasItem( ITEM )




Where ITEM is a valid item object, for example


$dataItems[2] would be item 2
$dataWeapons[4] would be weapon 4
$dataArmors[12] would be armor 12




and so on.


So for your condition, you would check


$gameParty.hasItem( ITEMA ) >= 1 && $gameParty.hasItem(ITEM😎 >= 2 && $gameParty.hasItem(ITEMC) >= 3




Assuming you have valid item objects.
Thank you both for the help!


Tsukihime, I am using this line for my "If" clause in the conditional branch:


$gameParty.hasItem(5) >= 1 && $gameParty.hasItem(6) >= 1 && $gameParty.hasItem(7) >= 3


This should check if the party has 1 or more of "item 5", 1 or more of "item 6", and 3 or more of "item 7", correct?


However, every time I test this out it doesn't work, the conditional branch always goes to the "else" clause instead. Did I mess up somewhere in the syntax? Thanks.
@GreyStone84 conditional branches already have a default check for 1 or more of an item on page 4, so for the if party has 1 or more of item a you wouldn't need a variable.  The other 2 items would need variables still though.
Try this


$gameParty.numItems($dataItems[5]) >= 1 && $gameParty.numItems($dataItems[6]) >= 1 && $gameParty.numItems($dataItems[7]) >= 3


if you want check weapon or armor replace $dataItems with $dataWeapons or $dataArmors
Thank you both for the help!


Tsukihime, I am using this line for my "If" clause in the conditional branch:


$gameParty.hasItem(5) >= 1 && $gameParty.hasItem(6) >= 1 && $gameParty.hasItem(7) >= 3


This should check if the party has 1 or more of "item 5", 1 or more of "item 6", and 3 or more of "item 7", correct?


However, every time I test this out it doesn't work, the conditional branch always goes to the "else" clause instead. Did I mess up somewhere in the syntax? Thanks.



Take a look at how an ITEM is written again.


It's not just a number.
Take a look at how an ITEM is written again.


It's not just a number.



Yup, I figured it out! Thanks for clarifying that.


By the way, is there a database or list of general syntax for rpgmaker mv somewhere? I would like to learn more about writing scripts.
Yup, I figured it out! Thanks for clarifying that.


By the way, is there a database or list of general syntax for rpgmaker mv somewhere? I would like to learn more about writing scripts.



There are some scripting videos available on youtube


For example


SumRndmDude https://www.youtube.com/channel/UCyqXLDebVx9rNnoSpcnNH3Q/playlists
SoulPour https://www.youtube.com/playlist?list=PLAhuV2yrS6nrkVwtEIjIC1isySa8l2F4h

There's this page I'm sort of building, but it's mostly small things used in script calls or formulas http://himeworks.com/wiki/index.php?title=MV_Formula_Library/Conditional_Formulas
There are some scripting videos available on youtube


For example


SumRndmDude https://www.youtube.com/channel/UCyqXLDebVx9rNnoSpcnNH3Q/playlists
SoulPour https://www.youtube.com/playlist?list=PLAhuV2yrS6nrkVwtEIjIC1isySa8l2F4h

There's this page I'm sort of building, but it's mostly small things used in script calls or formulas http://himeworks.com/wiki/index.php?title=MV_Formula_Library/Conditional_Formulas



Great, much appreciated!

Original thread: https://forums.rpgmakerweb.com/threads/checking-for-different-types-of-items-in-inventory.60500/