Inventory

Methods to interact with the inventory gametab.

_images/inventory.png

TRSInventory

Main record responsible with handling the inventory gametab.


Inventory.SetupGameTab

procedure TRSInventory.SetupGameTab();

Internal method used to setup the TRSInventory coordinates.

This is automatically called for you on the Inventory variable.


Inventory.IsOpen

function TRSInventory.IsOpen(): Boolean;

Returns true/false if the inventory is open.

Example:

WriteLn Inventory.IsOpen();

Inventory.Open

function TRSInventory.Open(): Boolean;

Attempts to open the inventory gametab.

Example:

WriteLn Inventory.Open();

Inventory.IsFull

function TRSInventory.IsFull(): Boolean;

Returns true/false if the inventory is full.

Example:

WriteLn Inventory.IsFull();

Inventory.IsSelected

function TRSInventory.IsSelected(slot: TBox): Boolean;
function TRSInventory.IsSelected(slot: Integer): Boolean; overload;
function TRSInventory.IsSelected(item: TRSItem): Boolean; overload;

Returns true/false if the specified slot or item is currently selected.

Example:

WriteLn Inventory.IsSelected('Vial');

Inventory.GetSelected

function TRSInventory.GetSelected(): Integer;

Returns the selected slot number if any. -1 is returned if no selected slot is found.

Example:

WriteLn Inventory.GetSelected();

Inventory.Select

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:

WriteLn Inventory.Select('Coins');

Inventory.Combine

function TRSInventory.Combine(slotA, slotB: Integer): Boolean;
function TRSInventory.Combine(itemA, itemB: TRSItem): Boolean; overload;

Attempts to combine 2 slots or 2 items.

Example:

WriteLn Inventory.Combine('Coins', 'Asgarnian ale');

Slots.RandomPattern

function TRSInventory.RandomPattern(): TIntegerArray;

Returns a random pattern of inventory slots.

Here is example code to generate and visually debug patterns:

{$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.
_images/inventoryrandompattern.gif

Inventory.Drop

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:

WriteLn Inventory.Drop('Oak logs');

Inventory.ShiftDrop

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:

WriteLn Inventory.ShiftDrop('Maple logs');

Inventory variable

Global TRSInventory variable.