How to Check for Multiple of the Same Item

Discussion in 'RPG Maker VX Ace' started by KholeG, Sep 7, 2015.

  1. KholeG

    KholeG Snek Veteran

    Messages:
    54
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    N/A
    Hi guys!

    I was wonder if there was a way I could check for multiple items at the same time in one script call.

    Basically I want to make a basic crafting system without a huge fancy script, and I want to be able to check for multiple items with an ID value and make sure the player has enough of the items with said ID value, all in one script call.

    Ex:

    Player wants to craft item "Fork Lance"

    Required Items:

    2 Flotsam

    3 Wood

    2 Shells

    Script then checks the player inventory for all 3 item IDs and then checks that there are enough of said item in the inventory.

    Thanks for the help!
     
    #1
  2. Chiakscare

    Chiakscare Resident Tifaholic Veteran

    Messages:
    489
    Likes Received:
    148
    Location:
    Crystal Lake, IL
    First Language:
    English
    You could bind items to variables, then have Conditional Branches that check for a total number of that item's variable.

    You'd only really need a script to make a crafting menu that shows the items and highlights them, etc; there's custom menu scripts available already; if you wanted the variable checking in the script itself, that's pretty easy to code; it's also easy to do in pure eventing.
     
    #2
  3. KholeG

    KholeG Snek Veteran

    Messages:
    54
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    N/A
    In another game I'd been working on I did the crafting by checking for every subsequent item and it was tedious.

    I have no idea how to script and I don't actually need a menu. Is there no way to call it in event as a script like;

    check item id in player inventory - true/false (once for each id)

    x number of item id = y (again once for each id)

    if both = true, activate switch ID z

    I can get around it with item variable binding, but that can also be tedious and I'm not quite sure how to do it properly.
     
    Last edited by a moderator: Sep 7, 2015
    #3
  4. Kes

    Kes Global Moderators Global Mod

    Messages:
    21,057
    Likes Received:
    10,702
    First Language:
    English
    Primarily Uses:
    RMVXA
    I think you mean event in this part, not script.  In RM scripts and events are 2 very different things, and you need to be clear in your terminology, otherwise a lot of confusion can occur.

    If you don't want to use a script, it can be done in a straightforward way in events, but it will be tedious (probably very tedious).  You will have to choose which option you find least bad.
     
    Last edited by a moderator: Sep 7, 2015
    #4
  5. KholeG

    KholeG Snek Veteran

    Messages:
    54
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    N/A
    No, actually I do mean script. By script, I mean the in event script. As in you use a script call in an event, and I'm referring to the script being called.
     
    #5
  6. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,640
    Likes Received:
    2,969
    Location:
    Philippines
    First Language:
    Tagalog
    If urbusing the script call conditional, you could always do

    If a and b and c and so on
     
    Last edited by a moderator: Sep 7, 2015
    #6
  7. KholeG

    KholeG Snek Veteran

    Messages:
    54
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    N/A
    What do you mean by that exactly? In my description?
     
    #7
  8. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,640
    Likes Received:
    2,969
    Location:
    Philippines
    First Language:
    Tagalog
    Ibmean you can do

    If $game_variables[1] == 2 and $game_variables[2] == 5 and so... on

    As a condition so you only use 1 conditional to check for all required itens
     
    Last edited by a moderator: Sep 7, 2015
    #8
  9. KholeG

    KholeG Snek Veteran

    Messages:
    54
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    N/A
    Alright, that makes a little more sense
     
    #9
  10. Kes

    Kes Global Moderators Global Mod

    Messages:
    21,057
    Likes Received:
    10,702
    First Language:
    English
    Primarily Uses:
    RMVXA
    That is not a script in RM  terminology.  It is, as you say, a script call (i.e. a call to a script).  Scripts are what you see in the script editor.  You do not have scripts in events.

    You can, of course, use any form of words you like, but the chances are high that you will be misunderstood and potentially waste other peoples' time as they are quite likely to think you mean something else.
     
    #10
  11. KholeG

    KholeG Snek Veteran

    Messages:
    54
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    N/A
    My appologies, I'm still new to RM technology in the sense
     
    #11
  12. Kes

    Kes Global Moderators Global Mod

    Messages:
    21,057
    Likes Received:
    10,702
    First Language:
    English
    Primarily Uses:
    RMVXA
    np.

    Everything ends up with its own specialist terminology/jargon and I think in some other engines eventing is called scripting, so it can get very confusing.
     
    #12
  13. Andar

    Andar Veteran Veteran

    Messages:
    28,680
    Likes Received:
    6,595
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    It can be done by pure eventing, and a lot faster than that:

    Use the control variable command to get the number:


    control variable:game data:item in inventory


    then use conditional branch var >= number needed


    If the item is not in inventory, the control variable will load zero - no need to check the existance of the item in extra lines.


    The script line from Engr. Adiktuzmiko above still needs to fill the variables with the numbers, so it only combines several conditional branches into one line.


    I suggest you follow the first link in my signature (starting point) and work through the tutorials linked there, especially the "Variables Guide" as that will help you understand how to use variables more effectively.
     
    #13
  14. KholeG

    KholeG Snek Veteran

    Messages:
    54
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    N/A
    Thank you Andar, this really helped. I've got my issue all solved!
     
    #14

Share This Page