• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Add an Item to Item Storage

thor348

That's Oak to You
  • 132
    Posts
    12
    Years
    I've been searching and tinkering but to no avail. Is there a way to add an item directly to the Item Storage in the Players PC?
     
    I found that in the PokemonBag script section and tried it but it didn't work.

    EDIT:
    Okay, I played around some more and this works:

    Code:
    $PokemonGlobal.pcItemStorage.pbStoreItem(PBItems::item,quantity)
     
    Last edited:
    Couldn't figure out directly how to do this, so I wrote a little code. Apparently they were phasing out the pbStoreItem code in v. 20, which added items directly to the PC. However, instead of replacing it with an equivalent code in v. 20, the devs replaced it with code that just added items directly to the player's inventory.

    Blah blah blah, ignore the above. Here's the fix for you:



    In the Script Editor, go to UI_bag. Scroll to the very bottom. Add this:

    Code:
    #Adds an item directly to the Player's PC and kwatar is a dumb idiot
    def pbDepositItemStorage(item, qty = 1)
        if !$PokemonGlobal.pcItemStorage
              $PokemonGlobal.pcItemStorage = PCItemStorage.new
            end
        storage = $PokemonGlobal.pcItemStorage
        storage.add(item, qty)
    end

    It should look like this:
    [PokeCommunity.com] Add an Item to Item Storage



    Now, you can call this any time by running the script:
    Code:
    pbDepositItemStorage(<ITEM NAME>, <NUMBER OF ITEMS>)

    Like so:
    [PokeCommunity.com] Add an Item to Item Storage


    By the way, when you're putting this code in the events, don't forget you might need to run extendtext.exe because RPG Maker XP inserts spaces with line breaks into code and sometimes that breaks everything.


    Hope this helps!
     
    Back
    Top