Item Database and Easy Referencing how to?

Discussion in 'RPG Maker VX Ace' started by AeonSpark, Apr 1, 2015.

  1. AeonSpark

    AeonSpark Veteran Veteran

    Messages:
    102
    Likes Received:
    5
    First Language:
    English
    I wanted to know if there was a way of using variables and events to check items and whether they are in an inventory, without having to use individual variables for each item. 

    This is for a shop based game, so essentially I want to check if an item is in stock, but due to the nature of the game it'd mean making a variable/common event for each item to check its in.

    I was just curious if there was a script/event/variable I'm missing.

    It would probably look something like this (except if I knew code):

    "Check for Item X (where X is an item) is greater than or equal to 1"

    A normal conditional branch would be fine for checking individual items, but if there was a way to customise 'X' so I could apply it to an list of items in a database - i.e. Potion = 1, Hi-Potion = 2. that would save tons of time and be much neater, having one line of script instead of around 100-200 conditional variables/common events. 

    So that I could run the script in a way that running the script where X is 1 it would check for Potion and then would run a conditional effect based from there (i.e. display the item) 

    I may have explained this either not well enough or too much, but I'd appreciate any help with this :)

    Thanks! 
     
    #1
  2. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    4,521
    Likes Received:
    3,773
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    You're a little unclear.  Are you trying to check the party's inventory, or some separate "shop inventory" type of construct?

    The player's inventory is easy.  I believe the correct syntax is $game_party.has_item?($data_items[x]) where x is the ID of the item you're looking up.  It will return either true or false.  Be sure to use weapons or armors instead of items if you're trying to get the number of a weapon or armor in your party's inventory.

    If you want to include party members' equipment, use $game_party.has_item?($data_items[x], true)

    If you want to return the number of items the party has instead of a true/false value, use $game_party.item_number($data_items[x]) -- note that you cannot easily include party members' current equipment in this check.

    Finally, if you're using some separate construct to manage other inventories besides that of the party, you'll have to give us more detail about how it's set up if you want help about how to check whether those "inventories" have an item or not.
     
    #2
  3. AeonSpark

    AeonSpark Veteran Veteran

    Messages:
    102
    Likes Received:
    5
    First Language:
    English
    Thats great!
    Thank you!

    And to be clear it would be the players inventory so the script you displayed there would be perfect! ^^

    I'll give this a go now, thanks very much :D
     
    #3
  4. AeonSpark

    AeonSpark Veteran Veteran

    Messages:
    102
    Likes Received:
    5
    First Language:
    English
    Okay, now I've got that!

    Just out of curiosity, is there any way to have that command be a constant common event and have a way of changing X in the script dependent on what is needed to be checked? Or would it be a case of running a different script for every item in list? 

    Thanks!
     
    #4
  5. CharcoalKidd

    CharcoalKidd Villager Member

    Messages:
    27
    Likes Received:
    10
    First Language:
    English
    A little thing I find myself using a lot is local variables in scripts. On the line above $game_party.has_item?($data_items[x]), set @currentitem (or something of that capacity) to $game_variables[x], then replace $data_items[x] with $data_items[@currentitem]. Then you just set whatever variable you used to decide what item you're checking for. Comes out looking like this;

         @currentitem = $game_variables[x]

         if $game_party.has_item?($data_items[@currentitem]

              blah blah blah.

    I don't know for sure if that will work, but off the top of my head it seems fine.
     
    Last edited by a moderator: Apr 2, 2015
    #5
  6. Shaz

    Shaz Veteran Veteran

    Messages:
    37,969
    Likes Received:
    11,624
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    If you don't care how many of the item you have in inventory - just whether you have <at least one> or not - use the Item [item name] in Inventory check in the Conditional Branch event command.


    All the suggestions above are about using script calls. But they are all available within the conditional branch as a pre-set check.
     
    #6
  7. AeonSpark

    AeonSpark Veteran Veteran

    Messages:
    102
    Likes Received:
    5
    First Language:
    English
    This what was I was scratching my head about, there doesn't seem to be an obvious way in which to have one call for multiple items. 

    For example, in my game the player owns a shop, they can approach a shop display and in an event, they are able to select an item from their inventory to display.

    It feels like I must be missing something if I would have to make 50 event pages, 50 variables, and then 50 switches (for a visual display) in order to have the player be able to select 50 different items from their inventory, unless this has a super simple solution I'm just not seeing. ;__;
     
    #7
  8. Shaz

    Shaz Veteran Veteran

    Messages:
    37,969
    Likes Received:
    11,624
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    What exactly are you attempting to do? Forget explaining HOW you're trying to do it - why do you want to select one of 50 different items from your inventory in a shop display event? I take it you're not using the normal shop processing. What sort of shop is this? Why does the player need to select something from inventory?
     
    #8
  9. Korokage

    Korokage Veteran Veteran

    Messages:
    56
    Likes Received:
    9
    First Language:
    English
    To me it sounds like he's trying to set up something along the lines of the game Recettear. The player owns a shop and sets up displays that shows off their wares but can also pull items from "the back" (aka the player's inventory) when needed.

    @Aeonspark: As far as I've seen, there doesn't seem to be a way to set up a conditional that checks for every item at once. There could be a conditionals script that could do it, but I don't go looking for scripts overly often so don't quote me on that.
     
    #9
  10. AeonSpark

    AeonSpark Veteran Veteran

    Messages:
    102
    Likes Received:
    5
    First Language:
    English
    Hey!

    And yeah the game Recettear was something I looked at before I started development to take a look at how someone else did it, so I was trying to base it on something like that to build a prototype of what I'd like my game to be. 

    And yup, you'd have a stock of items (which would be contained in the players inventory) and then you select a space in the shop (I've used tables) and use an event on the table pick an item from your inventory and then display it. 

    Which sounds simple in theory. 

    The problem would be, the way I've done it for now, for one table that displays two different items it has required 4 common events and 3 pages on one event, one table (the event being the item display as it changes) which I can now copy and paste as it does work, but I'd have to do this for every table in the shop, and thats just to display two different items. 

    Common Event 1 - Check the Inventory and set aside a Variable for those, for now I'm using White and Black as item names. 

    Common Event 2 - From a table without a display, display one item from a choice of White or Black, check if the player has the item in stock, and if so, activate a switch corresponding to the White or Black Item. 

    Common Event 3 - Change the Display on a Table that already has an item on it, this checks if a switch is active for White or Black and then gives the player a choice of which item to switch it with, it then swaps switches and Takes and Returns items. 

    Common Event 4  - A self contained Common Event to swap out the items, just to make the event listing in Common Event 3 a little clearer. 

    But this current solution will result in clutter by the time the game is done, and not ideal as I'm having to restrict a certain amount of items to one table in order to make it feasible (though this isn't the worst as I could just have tables act as upgrade holders, and have different tiered items be restricted to tiered tables) but this is why I brought the issue up.

    Again, its not super urgent as the current mode does work, but I just brought it up to see if there was a way of streamlining this process!

    Apologies if I've not been super clear but thanks for any help :)
     
    #10

Share This Page