Removing item from inventory based on variable?

Discussion in 'RGSS3 Script Requests' started by Koi, Sep 5, 2018.

  1. Koi

    Koi Veteran Veteran

    Messages:
    358
    Likes Received:
    14
    Location:
    Michigan
    First Language:
    English
    Primarily Uses:
    RMVXA
    I'm creating a potion making system in my game confined to a single event tile. It's going to allow the player to select anything from key items to add into the cauldron, whether or not it's the correct one in the correct order to make a specific potion. I'm using Select Key Items for this with a variable "KEY ITEMS", so I've got conditional branches for Variable [0053:KEY ITEMS] == ## removing the item numbered.

    But then I hit a snag when I realized I can't just focus on the correct item being chosen if I'm giving the player the ability to choose any item. If they choose the wrong item it still needs to be taken from the inventory. I figured I could do this with the same variable system, say Variable [0053:KEY ITEMS] == 10 removes item #10, but then I'd have to have 19+ conditional branches shoved into every time a choice prompt to put in an ingredient comes up.

    I don't know if there's any easier way to do this in the program, I'm assuming it would need a script.
     
    #1
  2. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,096
    Likes Received:
    7,230
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm going to move this to Script Requests, since you seem to think it will need one. But I'm wondering if it can't be solved by eventing, in which case, it might get moved again to Ace Support.
     
    #2
  3. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    3,627
    Likes Received:
    3,808
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    No need script, just script call
    Code:
    $game_party.lose_item($data_items[$game_variables[53]], 1)
    Edit: fixed the code
     
    #3
  4. Koi

    Koi Veteran Veteran

    Messages:
    358
    Likes Received:
    14
    Location:
    Michigan
    First Language:
    English
    Primarily Uses:
    RMVXA
    I'm sorry, I was sure I had posted this in script requests already.

    Thank you! Do you have any advice as to how to implement it? What does the 53 refer to? After all these years scripts of any kind are still very confusing to me.
     
    #4
  5. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    3,627
    Likes Received:
    3,808
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    Well you were using variable id 53 for storing item ID so
     
    #5
  6. Koi

    Koi Veteran Veteran

    Messages:
    358
    Likes Received:
    14
    Location:
    Michigan
    First Language:
    English
    Primarily Uses:
    RMVXA
    Woooow I'm dense.

    Anyway, I tried to implement it but it gave me an error message and crashed the game whenever I tried to add an ingredient.

    Here's where I added it in, right after the prompt to pick an item.

    [​IMG]

    But as soon as any item is picked, the game shows this:

    [​IMG]
     
    #6
  7. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    3,627
    Likes Received:
    3,808
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    Do not put it as separate line, use single line. Or are you unable to use single line?
     
    #7
  8. Koi

    Koi Veteran Veteran

    Messages:
    358
    Likes Received:
    14
    Location:
    Michigan
    First Language:
    English
    Primarily Uses:
    RMVXA
    I pasted the script in directly as you had written it for me. The program automatically split it into two lines.

    [​IMG]

    The box for the script input is too small.
     
    #8
  9. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    3,627
    Likes Received:
    3,808
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    So anyway, can you put it in a single line or not?
    Or are you not having this wide script box?
    [​IMG]

    If not we can go into an alternative, like
    Code:
    item = $data_items[$game_variables[53]]
    $game_party.lose_item(item, 1)
    
     
    #9
  10. Koi

    Koi Veteran Veteran

    Messages:
    358
    Likes Received:
    14
    Location:
    Michigan
    First Language:
    English
    Primarily Uses:
    RMVXA
    Maybe we're using different versions of RMVXA? Because my script box is not at all that width. But yes it works now thank you so much!
     
    #10
  11. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    3,627
    Likes Received:
    3,808
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    You might be using an old version of VXA, which has smaller script box.
    Maybe you can try to redownload VXA for the newest version.
     
    #11
  12. Koi

    Koi Veteran Veteran

    Messages:
    358
    Likes Received:
    14
    Location:
    Michigan
    First Language:
    English
    Primarily Uses:
    RMVXA
    I'm always nervous it'll do something weird to my game, like something will suddenly be incompatible.
     
    #12
  13. Zino97

    Zino97 Villager Member

    Messages:
    25
    Likes Received:
    0
    First Language:
    Russian
    #13
  14. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    3,627
    Likes Received:
    3,808
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    Honestly it's just MV stigma lol. VXA is safe.
     
    #14
  15. Koi

    Koi Veteran Veteran

    Messages:
    358
    Likes Received:
    14
    Location:
    Michigan
    First Language:
    English
    Primarily Uses:
    RMVXA
    Thank you so much! I actually already created a suitable event for what I needed, took me like 6 hours and it is functional so I'm content with it. But this will definitely be useful in any future games I make!

    What do you mean MV "stigma"?
     
    #15
  16. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    3,627
    Likes Received:
    3,808
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    MV tend to break your game when u update the program. VXA does not. Or even if it breaks, it should be easy to fix.
     
    #16

Share This Page