SlotInterface

Methods to interact slotted interfaces.

“Slotted 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 SlotInterface, but all the examples above do and you can access it through their Slots variable, for example:

Inventory.Slots;
Equipment.Slots;
Bank.Slots;

Note

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


TRSSlotInterface

Main record to handle a SlotInterface.

Note

Throughout this page Slots will always refer to a TRSSlotInterface variable unless specified otherwise.


Slots.Setup

procedure TRSSlotInterface.Setup(name: String; slots: TBoxArray; slotsFunction: function (): TBoxArray of object = nil);

Setup method of the SlotInterface.

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

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

You have 3 parameters:

  • name, simply used for debugging if something goes wrong, it will tell you which SlotInterface raised an exception.

  • slots which should be a static TBoxArray.

  • slotsFunction which should be a function that returns a TBoxArray useful for dynamic slot boxes.

Whatever boxes are passed to slots are only ever used if you slotsFunction is nil. In other words, if you set a slotsFunction that will always be the prefered way that TRSSlotInterface will use internally.

So if you are going to setup a function, you can leave slots as an emtpy array if you want. For example, here is how the TRSBank TRSSlotInterface could be setup:

Bank.Slots.Setup('Bank.Slots', [], @Bank.FindItemBoundaries);

In reality it’s setup like this:

Bank.Slots.Setup('Bank.Slots', Bank.SlotBoxes, @Bank.FindItemBoundaries);

Just in case people would like to access the bank’s static slots through it’s Slots variable.


Slots.Boxes

function TRSSlotInterface.Boxes(): TBoxArray;
function TRSSlotInterface.Boxes(slots: TIntegerArray): TBoxArray; overload;

Functions to return the slot boxes of the SlotInterface.

Example:

{$I WaspLib/osrs.simba}
begin
  ShowOnTarget(Inventory.Slots.Boxes());
end.
_images/slotboxes.png

You can optionally return only some of the boxes as well:

{$I WaspLib/osrs.simba}
begin
  ShowOnTarget(Inventory.Slots.Boxes([2,3,4,12,13,15,16]));
end.
_images/slotboxes2.png

Slots.Box

function TRSSlotInterface.Box(slot: Integer): TBox;

Return the box of the specified slot on the SlotInterface.

Example:

{$I WaspLib/osrs.simba}
begin
  ShowOnTarget(Inventory.Slots.Box(6));
end.
_images/slotbox.png

Slots.Near

function TRSSlotInterface.Near(slot: Integer; slots: TIntegerArray; maxDist: Single = 60): TIntegerArray;

From the slots array which should be an array of indices for Slots.Boxes, return the indices that are “near” slot based on the maxDist value.

Example:

{$I WaspLib/osrs.simba}
var
  indices: TIntegerArray;
begin
  indices := Inventory.Slots.Near(15, [0..27]);
  ShowOnTarget(Inventory.Slots.Boxes(indices));
end.
_images/slotsnear.png

Slots.RandomNear

function TRSSlotInterface.RandomNear(slot: Integer; slots: TIntegerArray; maxDist: Single = 60; distribution: ERandomDistribution = ERandomDistribution.GAUSS): Integer;

From the slots array which should be an array of indices for Slots.Boxes, return a random index that is “near” slot based on the maxDist value.

Example:

{$I WaspLib/osrs.simba}
var
  idx: Integer;
begin
  while True do
  begin
    idx := Inventory.Slots.RandomNear(13, [0..27]);
    ShowOnTarget(Inventory.Slots.Boxes([13, idx]));
    Sleep(100);
  end;
end.
_images/slotsrandomnear.gif

Slots.GetUnder

function TRSSlotInterface.GetUnder(pt: TPoint): Integer;

Returns the index of the box that is under pt.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Slots.GetUnder(Mouse.Position);
end.

Slots.GetUsed

function TRSSlotInterface.GetUsed(): TIntegerArray;

Returns the indices of the slots that contain an item.

Example:

{$I WaspLib/osrs.simba}
var
  indices: TIntegerArray;
begin
  indices := Inventory.Slots.GetUsed();
  ShowOnTarget(Inventory.Slots.Boxes(indices));
end.
_images/slotsgetused.png

Slots.GetUsed

function TRSSlotInterface.GetUsed(): TIntegerArray;

Returns the indices of the slots that don’t have an item.

Example:

{$I WaspLib/osrs.simba}
var
  indices: TIntegerArray;
begin
  indices := Inventory.Slots.GetEmpty();
  ShowOnTarget(Inventory.Slots.Boxes(indices));
end.
_images/slotsgetempty.png

Slots.IsUsed

function TRSSlotInterface.IsUsed(slot: TBox): Boolean;
function TRSSlotInterface.IsUsed(slot: Integer): Boolean; overload;

Returns True/False if the specified slot contains an item.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Slots.IsUsed(5);
end.

Slots.IsEmpty

function TRSSlotInterface.IsEmpty(slot: TBox): Boolean;
function TRSSlotInterface.IsEmpty(slot: Integer): Boolean; overload;

Returns True/False if the specified slot doesn’t have an item.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Slots.IsEmpty(5);
end.

Slots.IsFaded

function TRSSlotInterface.IsFaded(slot: TBox): Boolean;
function TRSSlotInterface.IsFaded(slot: Integer): Boolean; overload;

Returns True/False if the specified slot has an item and is faded. An item is usually faded for a few frames when you click it or when you drag it.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Slots.IsFaded(5);
end.

Slots.WaitFade

function TRSSlotInterface.WaitFade(slot: TBox; time: Integer = 200): Boolean;
function TRSSlotInterface.WaitFade(slot: Integer; time: Integer = 200): Boolean; overload;

Waits time milliseconds for Slots.IsFaded to return False for the specified slot.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Slots.WaitFade(5);
end.

Slots.Count

function TRSSlotInterface.Count(): Integer;

Returns the amount of slots that contain items.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Slots.Count();
end.

Slots.CountEmpty

function TRSSlotInterface.CountEmpty(): Integer;

Returns the amount of slots that do not contain items.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Slots.CountEmpty();
end.

Slots.WaitCount

function TRSSlotInterface.WaitCount(count: Int32; time: Int32 = 600; interval: Int32 = -1): Boolean;

Waits for time milliseconds for Slots.Count to return count.

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn Inventory.Slots.WaitCount(2);
end.

Slots.ReadStack

function TRSSlotInterface.ReadStack(slot: TBox): Integer;
function TRSSlotInterface.ReadStack(slot: Integer): Integer; overload;

Reads the stack amount of a slot.

If the slot has no item in it -1 is returned. If 0 is returned it means the slot has an item 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.Slots.ReadStack(0);
end.

Slots.Hover

procedure TRSSlotInterface.Hover(slot: Integer);

Hover the specified slot with the mouse.

Example:

{$I WaspLib/osrs.simba}
begin
  Inventory.Slots.Hover(0);
end.

Slots.Click

procedure TRSSlotInterface.Click(slot: Integer; button: EMouseButton = EMouseButton.LEFT);

Clicks the specified slot with the specified button.

Example:

{$I WaspLib/osrs.simba}
begin
  Inventory.Slots.Click(0);
end.

Slots.Move

function TRSSlotInterface.Move(slot, destination: Integer): Boolean;

If slot has an item, move it to slot destination.

Example:

{$I WaspLib/osrs.simba}
begin
  Inventory.Slots.Move(0, 6);
end.

Slots.Interact

function TRSSlotInterface.Interact(slot: Integer; option: String = ''): Boolean;

Interacts with slot if it has an item, with the specified option.

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.Slots.Interact(0, 'Drink');
end.