Bag

The **Bag** is the player's portable inventory, in which items are stored. It is accessible from the pause menu.

## The Bag

The Bag is accessible via the variable `$bag`, which is an instance of `class PokemonBag` (created with the code `$bag = PokemonBag.new`). It contains arrays representing the Bag's pockets, as well as an array that remembers which items are registered for quick use in the Ready menu, and some navigation-based variables.

There are several settings related to the Bag. These are:

```
# The names of each pocket of the Bag.
def self.bag_pocket_names
  return [
    _INTL("Items"),
    _INTL("Medicine"),
    _INTL("Poké Balls"),
    _INTL("TMs & HMs"),
    _INTL("Berries"),
    _INTL("Mail"),
    _INTL("Battle Items"),
    _INTL("Key Items")
  ]
end
# The maximum number of slots per pocket (-1 means infinite number).
BAG_MAX_POCKET_SIZE  = [-1, -1, -1, -1, -1, -1, -1, -1]
# Whether each pocket in turn auto-sorts itself by item ID number.
BAG_POCKET_AUTO_SORT = [false, false, false, true, true, false, false, false]
# The maximum number of items each slot in the Bag can hold.
BAG_MAX_PER_SLOT     = 999

```

## What you can do with an item

The things you can do with an item depend on what item it is.

 Read
 Give
 Toss
 Register/Deselect
 Make Mystery Gift

The player can also rearrange items in a pocket by selecting one and pressing the Z key. The item name turns red and the cursor changes, and it can then be moved around with the up/down keys. Pressing the Z key again returns the cursor to normal and leaves the item in its new position, while pressing the X key cancels the move.

A pocket which has been set to auto-sort itself will not let the player manually rearrange its contents.

## Registering an item

Registering an item makes it show up in the Ready menu, accessible from the overworld by pressing the D key. There is no limit to how many items can be registered at once. An item remains registered even if the player consumes it; if the player gains more of that item later, it will automatically reappear in the Ready menu. Unregistering an item can only be done in the Bag.

Any item with a UseInField item handler can be registered. This includes several Key Items such as the Bicycle and Super Rod, and also includes consumable items like Honey, Repel and Escape Rope.

The list of currently registered items is stored in the array `@registered_items` within `$bag`. This array is not an inventory in and of itself; remember that an item can be registered even while the player doesn't have it.

## Displaying items

Key Items, HMs and TMs don't have their quantities shown by default, because it is assumed that the player will only ever own one of each of these items. Despite this, they still have quantities just like any other item. Their quantities should have no bearing on the game, as checking for the presence of one of these items (with `$bag.has?(:BICYCLE)`) will only care whether there is at least 1 of them in the Bag. Even so, for the sake of neatness and logic, you should try to make sure the player is never given multiples of the same Key Item/HM/TM.

The quantity of a Key Item, HM or TM can be shown in the Bag by defining the "ShowQuantity" property for that item.

## Tips

* The Items pocket notoriously contains a lot of items compared to the other pockets, with potentially over 200 different items that go in it. Why not split this pocket's items up into others?
	+ The most obvious solution is to move all the held items into their own pocket. If you want to keep the same number of pockets overall, then the Held Items pocket could replace the Mail pocket. The mail items would be moved into the Items pocket (if indeed you have mail in your game).