Check for multiple items in inventory

Discussion in 'RPG Maker VX Ace' started by stezenjames, Feb 16, 2015.

  1. stezenjames

    stezenjames Warper Member

    Messages:
    1
    Likes Received:
    0
    First Language:
    English
    I'm trying to make an event so that the player can exchange 10 of one item to an NPC and he gives you an item back.  The problem I'm having is that he will give you the item even if you don't have the 10.

    I have it set up so variable 001 is set to "Have the item (of 10) in inventory"

    Variable 002 is set to 10

    Is this the way I go about this?  I just need some guidance on this.
     
    #1
  2. Warpmind

    Warpmind Twisted Genius Veteran

    Messages:
    914
    Likes Received:
    564
    Location:
    Outside Bergen, Norway
    First Language:
    Norwegian
    The... least graceless way I can come up with is simply a chain of ten nested Conditional Branches... The first checks if you have the item in stock, then removes one, the second checks for the item, then removes one, all the way to the tenth item; if at any point the player's inventory DOESN'T have the item in question, it refunds all the items that were subtracted with a message of "Sorry, not enough." If all ten are in place, the exchange is successfully made...

    Basically, it'd be built something like this (same thing up and down, got the middle because that'd be the most important bit):

    (Having a bit of trouble with image uploading, so linking to image file...)
    https://drive.google.com/file/d/0B7syyAkJltVAVnRzVndKMjBFMlU/view?usp=sharing

    It's not precisely pretty, but it's completely straightforward and self-contained.
     
    #2
  3. Susan

    Susan Veteran Veteran

    Messages:
    2,766
    Likes Received:
    8,389
    Location:
    somewhere on this planet~
    First Language:
    No idea...
    Primarily Uses:
    RMMV
    You can use a 'Conditional Branch' command and a script call to do this.

    In your Conditional Branch, go to the 'Script' option located in tab 4, then enter the following:

    $game_party.item_number($data_items[n]) >= 10

    where 'n' is the location of item in your database.
     
    #3
    Marsigne, Dalph and Warpmind like this.
  4. Andar

    Andar Veteran Veteran

    Messages:
    28,672
    Likes Received:
    6,594
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    The simplest way is to use a control variable command to read the number of items from the inventory, and then use a conditional branch to check if the variable is higher or equal 10.
     
    #4
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,911
    Likes Received:
    11,585
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    I've moved this thread to VX Ace Support - this is not a Tech Support issue. Please be sure to post your threads in the correct forum next time. Thank you.


    Control Variables to get the number of items


    Conditional branch to check the value
     
    #5
  6. Warpmind

    Warpmind Twisted Genius Veteran

    Messages:
    914
    Likes Received:
    564
    Location:
    Outside Bergen, Norway
    First Language:
    Norwegian
    Oh, yeah, that'd be smoother than my version, yeah. :3
     
    #6

Share This Page