# Inventory Methods to interact with the inventory gametab. ```{figure} ../../images/inventory.png ``` - - - ## TRSInventory Main record responsible with handling the inventory gametab. - - - ## Inventory.SetupGameTab ```pascal procedure TRSInventory.SetupGameTab(); ``` Internal method used to setup the {ref}`TRSInventory` coordinates. This is automatically called for you on the {ref}`Inventory variable`. - - - ## Inventory.IsOpen ```pascal function TRSInventory.IsOpen(): Boolean; ``` Returns true/false if the inventory is open. Example: ```pascal WriteLn Inventory.IsOpen(); ``` - - - ## Inventory.Open ```pascal function TRSInventory.Open(): Boolean; ``` Attempts to open the inventory gametab. Example: ```pascal WriteLn Inventory.Open(); ``` - - - ## Inventory.IsFull ```pascal function TRSInventory.IsFull(): Boolean; ``` Returns true/false if the inventory is full. Example: ```pascal WriteLn Inventory.IsFull(); ``` - - - ## Inventory.IsSelected ```pascal function TRSInventory.IsSelected(slot: TBox): Boolean; function TRSInventory.IsSelected(slot: Integer): Boolean; overload; ``` Returns true/false if the specified `slot` or `item` is currently selected. Example: ```pascal WriteLn Inventory.IsSelected('Vial'); ``` - - - ## Inventory.GetSelected ```pascal function TRSInventory.GetSelected(): Integer; ``` Returns the selected slot number if any. -1 is returned if no selected slot is found. Example: ```pascal WriteLn Inventory.GetSelected(); ``` - - - ## Inventory.Select ```pascal function TRSInventory.Select(slot: Integer; wait: Boolean = False): Boolean; function TRSInventory.Select(item: TRSItem; wait: Boolean = False): Boolean; overload; ``` Attempts to select the specified `slot` or `item`. If `wait` is set to true we wait for confirmation that we succeeded. Example: ```pascal WriteLn Inventory.Select('Coins'); ``` - - - ## Inventory.Combine ```pascal function TRSInventory.Combine(slotA, slotB: Integer): Boolean; function TRSInventory.Combine(itemA, itemB: TRSItem): Boolean; overload; ``` Attempts to combine 2 slots or 2 items. Example: ```pascal WriteLn Inventory.Combine('Coins', 'Asgarnian ale'); ``` - - - ## Slots.RandomPattern ```pascal function TRSInventory.RandomPattern(): TIntegerArray; ``` Returns a random pattern of inventory slots. Here is example code to generate and visually debug patterns: ```pascal {$I WaspLib/osrs.simba} var img, pimg: TImage; slots: TBoxArray; tpa: TPointArray; pattern: TIntegerArray; i: Integer; a, b: TPoint; begin img := Target.GetImage(); img.DrawColor := $00FFFF; slots := Inventory.Slots.Boxes(); for i := 0 to High(slots) do img.DrawBox(slots[i]); while True do begin pimg := img.Copy(); pimg.DrawColor := $0000FF; pattern := Inventory.RandomPattern(); b := slots[pattern[0]].RandomPointCenter(); for i := 0 to High(pattern)-1 do begin a := b; b := slots[pattern[i+1]].RandomPointCenter(); pimg.DrawLine(a, b); pimg.Show(); Sleep(50); end; end; end. ``` ```{figure} ../../images/inventoryrandompattern.gif ``` - - - ## Inventory.Drop ```pascal function TRSInventory.Drop(slots: TIntegerArray; attempts: Integer = 5): Boolean; function TRSInventory.Drop(items: TRSItemArray; pattern: TIntegerArray = []): Boolean; overload; ``` Attempts to drop the specified `slots` or `items`. Example: ```pascal WriteLn Inventory.Drop('Oak logs'); ``` - - - ## Inventory.ShiftDrop ```pascal function TRSInventory.ShiftDrop(slots: TIntegerArray; attempts: Integer = 5): Boolean; function TRSInventory.ShiftDrop(slots, pattern: TIntegerArray): Boolean; overload; function TRSInventory.ShiftDrop(items: TRSItemArray; pattern: TIntegerArray): Boolean; overload; ``` Attempts to shift drop the specified `slots` or `items`. You can optionally specify a "drop" pattern. If we determine that we can't shift drop because the setting is off, `TRSInventory.Drop()` is used as a fallback. Example: ```pascal WriteLn Inventory.ShiftDrop('Maple logs'); ``` - - - ## Inventory variable Global {ref}`TRSInventory` variable.