ItemInterface

Methods to interact item interfaces.

“Item interfaces” in WaspLib refers to any interface that is an item container.

In other words, if an interface has holds items, it’s both a SlotInterface and ItemInterface.

Examples of “item containers” are:

Just because an interface is an “item container”, does not mean it uses ItemInterface, but all the examples above do and you can access it through their Items variable, for example:

Inventory.Items;
Equipment.Items;
Bank.Items;

Note

Throughout this page examples, Inventory will be used in most of them but any interface that has a TRSItemInterface variable can used instead.


TRSItemInterface

Main record to handle a ItemInterface.

Note

Throughout this page Items will always refer to a TRSItemInterface variable unless specified otherwise.


Items.Setup

procedure TRSItemInterface.Setup(name: String; slots: ^TRSSlotInterface; discoverOffset: TPoint; checkFunc: function (): Boolean of object = nil);

Setup method of the ItemInterface.

All interfaces included in WaspLib that use a ItemInterface already call this automatically for you.

Unless you create your own, you don’t need to use it.

To setup a TRSItemInterface, your interface also needs a TRSSlotInterface and you need to pass a pointer to it through this.

checkFunc should a function to check if the interface is open. This is optional but recommended as it will avoid your scripts do actions by accident if the interface is not open in the first place for some reason.

For example, this is how Inventory and Bank setup their TRSItemInterface:

//Inventory:
Inventory.Slots.Setup('Inventory.Slots', TBoxArray.Create(GameTab.TopLeft.Offset(13,9), 4, 7, 31, 31, [11, 5]));
Inventory.Items.Setup('Inventory.Items', @Inventory.Slots, [0, 0], @Inventory.Open);
//Bank:
Bank.Slots.Setup('Bank.Slots', Bank.SlotBoxes, @Bank.FindItemBoundaries);
Bank.Items.Setup('Bank.Items', @Bank.Slots, [0, 1], @Bank.IsOpen);

Items.IndexOf

function TRSItemInterface.IndexOf(items: TRSItemArray): Integer;

Returns the index of the first item found in items.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.IndexOf(['abyssal whip', 'dragon scimitar']);
end.

Items.IndicesOf

function TRSItemInterface.IndicesOf(items: TRSItemArray): TIntegerArray;

Returns all the indices of the items found in the TRSItemInterface.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.IndicesOf(['abyssal whip', 'dragon scimitar']);
end.

Items.FindAny

function TRSItemInterface.FindAny(items: TRSItemArray; out slot: TBox): Boolean;

Returns a True/False if any item in items was found and returns it’s TBox through slot.

Example:

{$I WaspLib/osrs.simba}
var
  bounds: TBox;
begin
  if Inventory.Items.FindAny(['abyssal whip', 'cake'], bounds) then
    ShowOnTarget(bounds);
end.
_images/itemfind.png

Items.Find

function TRSItemInterface.Find(item: TRSItem; out slot: TBox): Boolean;
function TRSItemInterface.Find(items: TRSItemArray; out slot: Integer): Boolean; overload;
function TRSItemInterface.Find(item: TRSItem; out slot: Integer): Boolean; overload;

Returns a True/False if the specified item or items were found and returns their TBox or slot index through slot.

Example:

{$I WaspLib/osrs.simba}
var
  bounds: TBox;
begin
  if Inventory.Items.Find('cake', bounds) then
    ShowOnTarget(bounds);
end.
_images/itemfind.png

Items.FindAll

function TRSItemInterface.FindAll(items: TRSItemArray): TBoxArray;
function TRSItemInterface.FindAll(items: TRSItemArray; out slots: TIntegerArray): Boolean; overload;
function TRSItemInterface.FindAll(items: TRSItemArray; out boxes: TBoxArray): Boolean; overload;

This function has several signatures, so depending on which one you use the parameters and/or results will vary but it all should be self explanatory.

You can use this to know if all the specified items are visible in the ItemInterface and/or return their bounds as a TBoxArray.

Example:

{$I WaspLib/osrs.simba}
var
  boxes: TBoxArray;
begin
  boxes := Inventory.Items.FindAll(['abyssal whip', 'cake']);
  ShowOnTarget(boxes);
end.
_images/itemfindall.png

Items.Contains

function TRSItemInterface.Contains(item: TRSItem): Boolean;

Returns True/False if the specified item is visible in the interface.

Keep in mind for interfaces that can “contain” the item but it’s currently not visible like the Bank for example, this will return false.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.Contains('abyssal whip');
end.

Items.ContainsAny

function TRSItemInterface.ContainsAny(items: TRSItemArray): Boolean;

Returns True/False if any of the specified items is visible in the interface.

Keep in mind for interfaces that can “contain” an item but it’s currently not visible like the Bank for example, this will not make this return true.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.ContainsAny(['abyssal whip', 'cake']);
end.

Items.ContainsAll

function TRSItemInterface.ContainsAll(items: TRSItemArray): Boolean;

Returns True/False if all of the specified items are visible in the interface.

Keep in mind for interfaces that can “contain” an item but it’s currently not visible like the Bank for example, this will return false.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.ContainsAny(['abyssal whip', 'cake']);
end.

Items.FindDifferent

function TRSItemInterface.FindDifferent(items: TRSItemArray): TIntegerArray;

This one may be a little bit confusing but it returns the indices of all slots that have items that are not any of the specified items.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.FindDifferent(['abyssal whip', 'cake']);
end.

Items.ContainsDifferent

function TRSItemInterface.ContainsDifferent(items: TRSItemArray): Boolean;

Similar to Items.FindDifferent but returns a boolean if any slots have items that are not any of the specified items.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.ContainsDifferent(['abyssal whip', 'cake']);
end.

Items.Count

function TRSItemInterface.Count(items: TRSItemArray): Integer;
function TRSItemInterface.Count(item: TRSItem): Integer; overload;

Returns the amount of items or item that are/is visible in the interface.

Keep in mind for interfaces that can “contain” the item but it’s currently not visible like the Bank for example, this will not count those.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.Count(['abyssal whip', 'cake']);
end.

Items.WaitCount

function TRSItemInterface.WaitCount(items: TRSItemArray; count: Integer; time: Integer = 600; interval: Integer = -1): Boolean;
function TRSItemInterface.WaitCount(item: TRSItem; count: Integer; time: Integer = 600; interval: Integer = -1): Boolean; overload;

Waits time milliseconds for Items.Count to return the specified count for the specified items or item.

Keep in mind, like similar functions mentioned in this page, for interfaces that can “contain” the item but it’s currently not visible like the Bank for example, this will not count those.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.WaitCount(['abyssal whip', 'cake'], 10, 600);
end.

Items.ReadStack

function TRSItemInterface.ReadStack(item: TRSItem): Integer;

Reads the stack of the specified item if it’s visible on the interface.

Keep in mind, like similar functions mentioned in this page, for interfaces that can “contain” the item but it’s currently not visible like the Bank for example, this will not read those.

If the item if not found -1 is returned. If 0 is returned it means that the item was found but has no stack number.

This is important to keep in mind because in most interfaces, even if an item is stackable, if there’s only a quantity of 1 available, it won’t have a stack number.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.ReadStack('coins');
end.

Items.CountEx

function TRSItemInterface.CountEx(item: TRSItem): Integer;

Special counting method that will an item regardless of it being stackable or not.

To put it simply, if the item is stackable it will read it’s stack count, otherwise, it will return how many you have in the interface, currently visible.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.CountEx('coins');
end.

Items.Hover

function TRSItemInterface.Hover(item: TRSItem): Boolean;

Hover the specified item with the mouse.

If the item is not visible, nothing happens and this returns False.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.Hover('cake');
end.

Items.Click

function TRSItemInterface.Click(item: TRSItem; button: EMouseButton = EMouseButton.LEFT): Boolean;

Clicks the specified item with the specified button.

If the item is not visible, nothing happens and this returns False.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Items.Click('cake');
end.

Items.Move

function TRSItemInterface.Move(item: TRSItem; destination: Integer): Boolean; overload;
function TRSItemInterface.Interact(slot: Integer; option: String = ''): Boolean; overload;

If the specified item is visible, move it to slot destination.

If it’s not visible this returns False and nothing happens.

Example:

{$I WaspLib/osrs.simba}
begin
  Inventory.Items.Move('cake', 6);
end.

Items.Interact

function TRSItemInterface.Interact(item: TRSItem; option: String = ''): Boolean;

Interacts with item if it is visible with the specified option.

If item is not visible this returns False and nothing happens.

If option is empty or if option is the default UpText for the item this will simply left click it.

Example:

{$I WaspLib/osrs.simba}
begin
  Inventory.Items.Interact('Prayer potion(3)', 'Drop');
end.