# Inventory Methods to interact with the inventory. - - - ## Inventory.GetSlotBoxes ```pascal function TRSInventory.GetSlotBoxes(): TBoxArray; ``` Mainly used internally by TRSInventory methods. This function is used to return a TBoxArray of the inventory slots. Example: ```pascal Debug(Inventory.GetSlotBoxes()); ``` - - - ## Inventory.IsOpen ```pascal function TRSInventory.IsOpen(): Boolean; ``` Returns true if the inventory gametab is open, false if it's not. Example: ```pascal WriteLn Inventory.IsOpen(); ``` - - - ## Inventory.Open ```pascal function TRSInventory.Open(): Boolean; ``` Attempts to open the inventory, returns true if it succeeds. Example: ```pascal WriteLn Inventory.Open(); ``` - - - ## Inventory.PointToSlot ```pascal function TRSInventory.PointToSlot(P: TPoint): Int32; ``` Returns the inventory slot index which contains the TPoint `P`. Returns -1 if the point does not fall in any slots. Example: ```pascal var P: TPoint; var Slot: Int32; P := Inventory.GetSlotBox(15).Middle; // Example point Slot := Inventory.PointToSlot(P); WriteLn(Slot); // 15 ``` - - - ## Inventory.MouseSlot ```pascal function TRSInventory.MouseSlot(slot: Int32): Boolean; ``` Moves the mouse over the slot. Slot is an Integer between 0 and 27. Example: ```pascal if Inventory.HoverSlot(1) then WriteLn('Mouse is now over slot #1'); ``` - - - ## Inventory.ClickSlot ```pascal function TRSInventory.ClickSlot(slot: Int32; option: String = ''): Boolean; ``` Moves the mouse and clicks on the slot. Slot is an Integer between 0 and 27. If option is empty the slot is left clicked. Else a right click is performed and the option is selected from the choose option menu. Example: ```pascal if Inventory.ClickSlot(1) then WriteLn('Left clicked slot #1'); if Inventory.ClickSlot(1, 'Drop') then WriteLn('Right clicked and selected "Drop" on slot #1', 'Drop'); ``` - - - ## Inventory.IsSlotSelected ```pascal function TRSInventory.IsSlotSelected(Slot: Int32): Boolean; ``` Returns True if the slot is selected (white outline). Example: ```pascal if Inventory.IsSlotSelected(1) then WriteLn('Slot 1 is selected!'); ``` - - - ## Inventory.GetSelectedSlot ```pascal function TRSInventory.GetSelectedSlot(): Int32; ``` Returns the index of the selected slot (white outline). **-1** is returned if no slot is selected. Example: ```pascal WriteLn(Inventory.GetSelectedSlot()); ``` - - - ## Inventory.SetSelectedSlot ```pascal function TRSInventory.SetSelectedSlot(Slot: Int32): Boolean; ``` Set the slot as selected (white outline). Slot can be **-1** to unselect the currently selected slot. Example: ```pascal WriteLn(Inventory.GetSelectedSlot()); ``` - - - ## Inventory.RandomPattern ```pascal function TRSInventory.RandomPattern(): TIntegerArray; ``` Returns a random inventory pattern. Example: ```pascal Inventory.ShiftDrop(Inventory.RandomPattern()); ``` - - - ## Inventory.ErrorPattern ```pascal function TRSInventory.ErrorPattern(Pattern: TIntegerArray=DROP_PATTERN_REGULAR; ErrorChance:Int32=5): TIntegerArray; ``` Returns the passed in pattern slightly modified. Example: ```pascal Inventory.ShiftDrop(Iventory.ErrorPattern(Inventory.RandomPattern())); ``` - - - ## Inventory.Count ```pascal function TRSInventory.Count(): Int32; function TRSInventory.CountItem(Item: TRSItem): Int32; function TRSInventory.CountItems(items: TRSItemArray): Int32; function TRSInventory.CountItemStack(item: TRSItem): Int32; function TRSInventory.CountSlotStack(slot: Int32): Int32; ``` Counts how many items are in the inventory right now or slack amounts. Example: ```pascal WriteLn Inventory.Count(); WriteLn Inventory.CountItem('Shark'); WriteLn Inventory.CountItemStack('Air rune'); ``` - - - ## Inventory.IsFull ```pascal function TRSInventory.IsFull(): Boolean; ``` Returns true if the inventory is full. Example: ```pascal WriteLn Inventory.IsFull(); ``` - - - ## Inventory.WaitCount ```pascal function TRSInventory.WaitCount(Count: Int32; WaitTime: Int32; Interval: Int32 = -1): Boolean; ``` Wait **WaitTime** until the Inventory.Count() matches **Count**. Example: ```pascal Inventory.WaitCount(28, 5000); //Wait up to 5 seconds to have 28 items in the inventory. ``` - - - ## Inventory.RandomSlotNearby ```pascal function TRSInventory.RandomSlotNearby(Slot: Int32; Slots: TIntegerArray): Int32; ``` Randomly returns one of the **Slots** weighted towards **Slot** by distance. Example: ```pascal var Slot: Int32; Slot := Inventory.RandomSlotNearby(0, [0..27]); WriteLn('This slot is likely nearby slot 0'); WriteLn(Slot); ``` - - - ## Inventory.FindItems ```pascal function TRSInventory.FindItems(Items: TRSItemArray; out Slots: TIntegerArray): Boolean; ``` Attempts to find the items passed in **Items**. The function returns true if any item is found and the slots of the found items will be returned in **Slots**. Example: ```pascal var slots: TIntegerArray; begin if Inventory.FindItems(['Shark', 'Lobster'], slots) then WriteLn('The slots that have sharks and lobsters are: ', slots); end; ``` - - - ## Inventory.FindItem ```pascal function TRSInventory.FindItem(Item: TRSItem; out Slots: TIntegerArray): Boolean; function TRSInventory.FindItem(item: TRSItem; out slot: Int32): Boolean; overload; ``` Attempts to find the item passed in **Item**. The function returns true if the item was found can be used to return a single slot or all slots containing the item. Example: ```pascal var slots: TIntegerArray; slot: Int32; begin if Inventory.FindItem('Shark', slots) then WriteLn('The slots that have sharks are: ', slots); if Inventory.FindItem('Shark', slot) then WriteLn('The first slot that has a shark is: ', slot); end; ``` - - - ## Inventory.Contains ```pascal function TRSInventory.ContainsAny(items: TRSItemArray): Boolean; function TRSInventory.ContainsItem(item: TRSItem): Boolean; function TRSInventory.ContainsAll(items: TRSItemArray): Boolean; ``` Returns true if the inventory contains an `item` or `items`. Example: ```pascal WriteLn Inventory.ContainsAny(['Shark', 'Lobster']); WriteLn Inventory.ContainsItem('Shark'); WriteLn Inventory.ContainsAll(['Shark', 'Lobster', 'Tuna']); ``` - - - ## Inventory.Discover ```pascal function TRSInventory.DiscoverAllEx(): array of TRSItemArray; function TRSInventory.DiscoverAll(): TRSItemArray; function TRSInventory.Discover(slot: Int32): TRSItemArray; ``` Returns possible items found in the inventory, either in a single slot or all of them. The extended version returns an `array of TRSItemArray` while the others return a flat `TRSItemArray`. Example: ```pascal if Inventory.Open() then WriteLn Inventory.DiscoverAll(); WriteLn Inventory.Discover(0); ``` - - - ## Inventory.MouseItem ```pascal function TRSInventory.MouseItem(Item: TRSItem): Boolean; ``` Hover **Item** in the inventory. Example: ```pascal if Inventory.MouseItem('Bronze arrows') then ChooseOption.Select('Drop'); ``` - - - ## Inventory.ClickItem ```pascal function TRSInventory.ClickItem(Item: TRSItem; Option: String = ''): Boolean; ``` Clicks **Item** in the inventory. If **Option** is specified that option will be selected with right click if it exists. Example: ```pascal WriteLn Inventory.ClickItem('Attack potion(3)'); WriteLn Inventory.ClickItem('Ashes', 'Drop'); ``` - - - ## Inventory.Use() ```pascal function TRSInventory.Use(slot, otherSlot: Int32): Boolean; function TRSInventory.Use(Item, OtherItem: TRSItem): Boolean; overload; ``` Use 2 slots or items on one another. Example: ```pascal WriteLn Inventory.Use('Knife', 'Oak logs'); ``` - - - ## Inventory.Drop ```pascal function TRSInventory.RightClickDrop(slots: TIntegerArray): Boolean; function TRSInventory.RightClickDrop(items: TRSItemArray; pattern: TIntegerArray): Boolean; overload; function TRSInventory.ShiftDrop(slots: TIntegerArray): Boolean; function TRSInventory.ShiftDrop(items: TRSItemArray; pattern: TIntegerArray): Boolean; overload; ``` Right click or shift drops `slots` or `items` specified. If `items` are passed in, you also have to specify a `pattern` to use. Shift dropping falls back to right click dropping if `TRSInventory.ShiftEnabled` is set to false. Example: ```pascal // Right click drop maple & willow logs in the snake pattern Inventory.RightClickDrop(['Maple logs', 'Willow logs'], DROP_PATTERN_SNAKE); // Shift drop maple & willow logs in the snake pattern Inventory.ShiftDrop(['Maple logs', 'Willow logs'], DROP_PATTERN_SNAKE); ``` - - - ## var Inventory Global TRSInventory variable.