GrandExchange

Methods to interact with the GrandExchange interface:

../../images/ge_interface.png

The GrandExchange is a very complex interface, probably the most complex available in game and for that reason, the functionality to fully interact with it is split into multiple files and records:


EGEOfferStatus

EGEOfferStatus = enum(NONE, PROGRESSING, COMPLETED, ABORTED);

Enum to represent the Grand Exchange offer slot states.


EGESlotType

EGESlotType = enum(EMPTY, SELL, BUY);

Enum to represent the type of Grand Exchange offer slot.


TGrandExchangeSlot

Record that represents a slot in the GrandExchange interface.

When you want to interact with a Grand Exchange slot you should do it through the TGrandExchange.Slots array, which is an array of this type.

The next examples will be showing how this is done with random slot numbers.

If you want to visualize what the TGrandExchangeSlot has to offer are you can use this short script:

{$I WaspLib/main.simba}
var
  img: TImage;
  slot: TGrandExchangeSlot;
begin
  img := Target.GetImage();
  for slot in GrandExchange.Slots do
  begin
    case slot.GetType() of
      EGESlotType.EMPTY:
      begin
        img.DrawColor := $00FFFF;
        img.DrawBox(slot.Bounds);
        img.DrawColor := $0000FF;
        img.DrawBox(slot.Header);
        img.DrawColor := $FF00FF;
        img.DrawBox(slot.BuyButton);
        img.DrawColor := $FFFF00;
        img.DrawBox(slot.SellButton);
      end;

      EGESlotType.SELL, EGESlotType.BUY:
      begin
        img.DrawColor := $00FFFF;
        img.DrawBox(slot.Bounds);
        img.DrawColor := $0000FF;
        img.DrawBox(slot.Header);
        img.DrawColor := $FF00FF;
        img.DrawBox(slot.ItemBox);
        img.DrawColor := $FFFF00;
        img.DrawBox(slot.ItemNameBox);
        img.DrawColor := $FFFFFF;
        img.DrawBox(slot.StatusBox);
        img.DrawColor := $0000FF;
        img.DrawBox(slot.ValueBox);
      end;
    end;
  end;

  img.Show();
end.
../../images/ge_slots.png

TGrandExchangeSlot.GetType

function TGrandExchangeSlot.GetType(): EGESlotType;

Returns the EGESlotType of the slot. This also sets the TGrandExchangeSlot.Typ to the result in case you want to access it later without calling this.

WaspLib will also try to keep TGrandExchangeSlot.Typ updated when you interact with the GrandExchange but it cannot track things a user might do manually.

Example:

WriteLn GrandExchange.Slots[2].GetType();

TGrandExchangeSlot.Contains

function TGrandExchangeSlot.Contains(item: TItem): Boolean;

Returns the TItem of the slot.

If the slot is empty an empty string is returned.

Example:

WriteLn GrandExchange.Slots[0].Contains('Abyssal whip');

TGrandExchangeSlot.Discover

function TGrandExchangeSlot.Discover(): TItemArray;

Uses item discover to return a TItemArray of the possible items in the slot.

If the slot is empty an empty array is returned.

Example:

WriteLn GrandExchange.Slots[5].Discover();

TGrandExchangeSlot.Item

property TGrandExchangeSlot.Item: TItem;

Reads the item text in the offer slot.

Example:

WriteLn GrandExchange.Slots[7].Item;

TGrandExchangeSlot.Value

property TGrandExchangeSlot.Value: Integer;

Reads the value text in the offer slot and returns it as an Integer.

Example:

WriteLn GrandExchange.Slots[3].Value;

TGrandExchangeSlot.Quantity

property TGrandExchangeSlot.Quantity: Integer;

Returns the quantity text in the offer slot as an Integer.

Example:

WriteLn GrandExchange.Slots[4].Quantity;

TGrandExchangeSlot.TotalValue

property TGrandExchangeSlot.TotalValue: Integer;

Returns the total value of the offer slot. Taking into account the Grand Exchange tax for sell offers.

Example:

WriteLn GrandExchange.Slots[5].TotalValue;

TGrandExchangeSlot.Status

property TGrandExchangeSlot.Status: EGEOfferStatus;

Returns the slot EGEOfferStatus status.

Example:

WriteLn GrandExchange.Slots[2].Status;

TGrandExchangeSlot.Progress

property TGrandExchangeSlot.Progress: Integer;

Returns the progress percentage of the slot.

Example:

WriteLn GrandExchange.Slots[2].Progress;

TGrandExchangeSlot.Open

function TGrandExchangeSlot.Open(): Boolean;

Attempts to open the GrandExchangeOffer status screen of an existing offer.

Example:

WriteLn GrandExchange.Slots[1].Open();

TGrandExchangeSlot.Buy

function TGrandExchangeSlot.Buy(): Boolean;

Attempts to open the GrandExchangeOffer screen with the buy button.

Example:

WriteLn GrandExchange.Slots[2].Buy();

TGrandExchangeSlot.Sell

function TGrandExchangeSlot.Sell(): Boolean;

Attempts to open the GrandExchangeOffer screen with the sell button.

Example:

WriteLn GrandExchange.Slots[2].Sell();

TGrandExchangeSlot.Abort

function TGrandExchangeSlot.Abort(): Boolean;

Attempts to abort an ongoing offer in the slot.

Example:

WriteLn GrandExchange.Slots[3].Abort();

TGrandExchange

Record responsible to handle the GrandExchange interface.


GrandExchange.SetupInterface

procedure TGrandExchange.SetupInterface();

Internal method used to setup the TGrandExchange coordinates. This is automatically called for you on the GrandExchange variable.


GrandExchange.IsOpen

function TGrandExchange.IsOpen(): Boolean;

Returns true if the Grand Exchange is open.

Example:

WriteLn GrandExchange.IsOpen();

GrandExchange.WaitOpen

function TGrandExchange.WaitOpen(time: Integer; interval: Integer = -1): Boolean;

Returns true if the Grand Exchange is open within time milliseconds.

Example:

WriteLn GrandExchange.WaitOpen();

GrandExchange.Close

function TGrandExchange.Close(escape: Boolean): Boolean;
function TGrandExchange.Close(escapeProbability: Single = 0): Boolean; overload;

Closes the GrandExchange, Depending on escape or `escapeProbability the function will either click the button or press escape key.

Example:

 WriteLn GrandExchange.Close();

GrandExchange.GetEmptySlots

function TGrandExchange.GetEmptySlots(): TGrandExchangeSlotArray;

Returns a TGrandExchangeSlotArray of the empty slots available.

Example:

{$I WaspLib/main.simba}
var
  img: TImage;
  slot: TGrandExchangeSlot;
begin
  img := Target.GetImage();
  img.DrawColor := $00FFFF;
  for slot in GrandExchange.GetEmptySlots() do
    img.DrawBox(slot.Bounds);
  img.Show();
end.
../../images/ge_emptyslots.png

GrandExchange.IndexOfEmptySlot

function TGrandExchange.IndexOfEmptySlot(): Integer;

Returns the index of the first empty slot available.

Example:

WriteLn GrandExchange.IndexOfEmptySlot();

GrandExchange.GetEmptySlot

function TGrandExchange.GetEmptySlot(): TGrandExchangeSlot;

Returns a TGrandExchangeSlot that is empty.

Example:

{$I WaspLib/main.simba}
begin
  ShowOnTarget(GrandExchange.GetEmptySlot().Bounds);
end.
../../images/ge_emptyslot.png

TGrandExchange.Collect

function TGrandExchange.Collect(): Boolean;

Attempts to Collect from the Grand Exchange.

In case of failure, returns False.

Example:

WriteLn GrandExchange.Collect();

GrandExchange variable

Global TGrandExchange variable.