• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

[Scripting Question] How to make the game identify the limit of items in the bag automatically and if, only if it is full, these items are automatically sent to PC Storage

  • 107
    Posts
    4
    Years
    • Seen Apr 27, 2023
    How to make the game identify the limit of items in the bag automatically and if, only if it is full, these items are automatically sent to PC Storage?
     
    if X == Settings::BAG_MAX_PER_SLOT

    Code:
    # There are two more other 'receive item' methods, you'll have to add the edits to each of them before the 'return false'.
    # If this don't work, oh well. You'll get a sense of what you should do and likely make it work.
    
    def pbReceiveItem(item,quantity=1)
      item = GameData::Item.get(item)
      return false if !item || quantity<1
      itemname = (quantity>1) ? item.name_plural : item.name
      pocket = item.pocket
      move = item.move
      meName = (item.is_key_item?) ? "Key item get" : "Item get"
      if item == :LEFTOVERS
        pbMessage(_INTL("\\me[{1}]You obtained some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
      elsif item.is_machine?   # TM or HM
        pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,GameData::Move.get(move).name))
      elsif quantity>1
        pbMessage(_INTL("\\me[{1}]You obtained {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname))
      elsif itemname.starts_with_vowel?
        pbMessage(_INTL("\\me[{1}]You obtained an \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
      else
        pbMessage(_INTL("\\me[{1}]You obtained a \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
      end
      if $PokemonBag.pbStoreItem(item,quantity)   # If item can be added
        pbMessage(_INTL("You put the {1} away\\nin the <icon=bagPocket{2}>\\c[1]{3} Pocket\\c[0].",
           itemname,pocket,PokemonBag.pocketNames()[pocket]))
        return true
      end
    # Edits Starts Here. After the previous line of code, the original method will return false, indicating item cannot be added to bag, the 'custom edits' here tells the game to try to store it to PC before that return false.
      if $PokemonGlobal.pcItemStorage(item,quantity)
        pbMessage(_INTL("Your bag is full, the {1} have been sent to PC storage instead.",
           itemname))
        return true
      else
        pbMessage(_INTL("Your bag and PC is full,  {1} could not be obtained.",
           itemname))
      end
    # Edits Ends Here
      return false   # Can't add the item
    end
     
    Last edited:
    if X == Settings::BAG_MAX_PER_SLOT

    Code:
    # There are two more other 'receive item' methods, you'll have to add the edits to each of them before the 'return false'.
    # If this don't work, oh well. You'll get a sense of what you should do and likely make it work.
    
    def pbReceiveItem(item,quantity=1)
      item = GameData::Item.get(item)
      return false if !item || quantity<1
      itemname = (quantity>1) ? item.name_plural : item.name
      pocket = item.pocket
      move = item.move
      meName = (item.is_key_item?) ? "Key item get" : "Item get"
      if item == :LEFTOVERS
        pbMessage(_INTL("\\me[{1}]You obtained some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
      elsif item.is_machine?   # TM or HM
        pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,GameData::Move.get(move).name))
      elsif quantity>1
        pbMessage(_INTL("\\me[{1}]You obtained {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname))
      elsif itemname.starts_with_vowel?
        pbMessage(_INTL("\\me[{1}]You obtained an \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
      else
        pbMessage(_INTL("\\me[{1}]You obtained a \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
      end
      if $PokemonBag.pbStoreItem(item,quantity)   # If item can be added
        pbMessage(_INTL("You put the {1} away\\nin the <icon=bagPocket{2}>\\c[1]{3} Pocket\\c[0].",
           itemname,pocket,PokemonBag.pocketNames()[pocket]))
        return true
      end
    # Edits Starts Here. After the previous line of code, the original method will return false, indicating item cannot be added to bag, the 'custom edits' here tells the game to try to store it to PC before that return false.
      if $PokemonGlobal.pcItemStorage(item,quantity)
        pbMessage(_INTL("Your bag is full, the {1} have been sent to PC storage instead.",
           itemname))
        return true
      else
        pbMessage(_INTL("Your bag and PC is full,  {1} could not be obtained.",
           itemname))
      end
    # Edits Ends Here
      return false   # Can't add the item
    end

    Everything you help me, so I fall in love, thank you!
     
    Back
    Top