Grand Exchange

The grandexchange file holds functions and procedures that are used to interact with the runescape Grand Exchange.

The source for this file can be found here.

Consts, Types, Vars

The following constants, types and variables are used throughout the collectBox methods.

const Grand Exchange Tabs

Constants that represent the two grandExchange tabs

  • GE_TAB_EXCHANGE
  • GE_TAB_HISTORY

type TRSGrandExchange

type
  TRSGrandExchange = type TRSInterface;

A type that stores the Grand Exchange interface properties.

var grandExchange

var
  grandExchange: TRSGrandExchange;

A variable through which scripters can access the TRSGrandExchange type methods.

TRSGrandExchange methods

The following methods should be called through the grandExchange variable.

Example:

if grandExchange.isOpen() then
  writeln('It''s open');

isOpen

function TRSGrandExchange.isOpen(waitTime: integer = 0): boolean;

Returns true if the grandExchange is open. The optional waitTime parameter (default = 0) is the maximum time (in milliseconds) it will keep looking.

Note

  • by The Mayor
  • Last Updated: 14 January 2015 by The Mayor

Example:

if grandExchange.isOpen() then
  writeln('The grandExchange is open!');

close

function TRSGrandExchange.close(escape: boolean = true): boolean;

Returns true if the grandExchange is successfully closed. It uses the ESC key by default, but the escape parameter can be set to false to close via the mouse.

Note

  • by The Mayor
  • Last Updated: 6 July 2015 by The Mayor

Example:

if grandExchange.close() then
  writeln('Closed the grandExchange');

openTab

function TRSGrandExchange.openTab(tab: Integer): Boolean;

Opens the grandExchange tab tab . The tab parameter should be one of the two tab constants at the top of this page.

Note

  • by The Mayor
  • Last Updated: 7 July 2016 by SlipperyPickle

Example:

grandExchange.openTab(GE_TAB_HISTORY);

getPackSlotBox

function TRSGrandExchange.getPackSlotBox(slot: integer): TBox;

Returns a TBox of the pack slot slot in the grandExchange interface.

Note

  • by The Mayor
  • Last Updated: 7 July 2016 by SlipperyPickle

Example:

var
  b: TBox;
begin
  b := grandExchange.getPackSlotBox(1);
  mouseBox(b, MOUSE_MOVE);
end;

collectSlot

function TRSGrandExchange.collectSlot(geSlot: integer): boolean;

Returns true if it collects coins and/or items from the completed or aborted slot geSlot .

Note

  • by The Mayor
  • Last Updated: 7 July 2016 by SlipperyPickle

Example:

grandExchange.collectSlot(2);

waitCollectSlot

function TRSGrandExchange.waitCollectSlot(geSlot, maxTime: integer): boolean;

Returns true if it collects coins and/or items from the completed or aborted slot geSlot . Waits up to maxTime for geSlot to finish selling.

Note

  • by The Mayor
  • Last Updated: 12 March 2015 by The Mayor

Example:

grandExchange.waitCollectSlot(2, 60000); // Wait up to 1 minute to collect slot 2

collectAllSlots

procedure TRSGrandExchange.collectAllSlots(toInventory: boolean = true): boolean;

Collects all coins and items to either the inventory or the bank depending on the toInventory paramter (default = true) via the collect buttons.

Note

  • by The Mayor
  • Last Updated: 27 July 2015 by Clarity

Example:

grandExchange.collectAllSlots(false); // Collect all to bank

abortSlot

function TRSGrandExchange.abortSlot(geSlot: integer; collect: boolean = true): boolean;

Returns true if it aborts the slot geSlot. If the collect parameter is set to true it will also collect the items and gold from the aborted offer.

Note

  • by The Mayor
  • Last Updated: 27 July 2015 by Clarity

Example:

grandExchange.abortSlot(2);
grandExchange.abortSlot(2, false); // To leave items in the aborted offer slot

abortAllSlots

procedure TRSGrandExchange.abortAllSlots(collect: boolean);

Aborts all slots that are not currently empty. If the collect parameter is set to true, it will also collect all items and gold.

Note

  • by The Mayor
  • Last Updated: 12 March 2015 by The Mayor

Example:

grandExchange.abortAllSlots();

getPercentDone

function TRSGrandExchange.getPercentDone(geSlot: integer): integer;

Returns the percentage toward completion for the offer in geSlot .

Note

  • by turpinator
  • Last Updated: 7 July 2016 by SlipperyPickle

Example:

var
  per: Integer;
begin
  per := grandExchange.getPercentDone(2);
  writeLn('Slot 2 is ' + toStr(per) + ' percent complete!');
end;

sellItem

function TRSGrandExchange.sellItem(packSlot: integer; price, quantity: string; waitCollect: boolean = false; waitTime: integer = 10000): boolean;

Returns true if it sells the item in backpack slot packSlot . If waitCollect is set to true, it will wait the specified waitTime for the offer to complete before collecting the resulting gold.

The price parameter is a string - valid options are:

  • ‘mid’ : GE mid price button
  • ‘-5’ : 5% below mid price button
  • ‘+5’ : 5% above mid price button
  • Any other number : It will enter the price

The quantity parameter is a string - valid options are:

  • ‘1’ : ‘1’ button
  • ‘10’ : ‘10’ button
  • ‘100’ : ‘100’ button
  • ‘all’ : ‘All’ button (Selling ONLY)
  • Any other number : It will enter the quantity

Note

  • by The Mayor
  • Last Updated: 7 July 2016 by SlipperyPickle

Example:

  // Sell all of item in backPack slot 1 for mid price
grandExchange.sellItem(1, 'mid', 'all');

  // To sell 100 of the item in backPack slot 1, for 1500gp each
grandExchange.sellItem(1, '1500', '100');

  // As above, but waits up to 20 seconds for completion before collecting the coins
grandExchange.sellItem(1, '1500', '100', true, 20000);

buyItem

function TRSGrandExchange.buyItem(itemName, price, quantity: string; waitCollect: boolean = false; waitTime: integer = 10000): boolean;

Returns true if it buys the item itemName . If waitCollect is set to true, it will wait the specified waitTime for the offer to complete before collecting the resulting gold and items.

The price parameter is a string - valid options are:

  • ‘mid’ : GE mid price button
  • ‘-5’ : 5% below mid price button
  • ‘+5’ : 5% above mid price button
  • Any other number : It will enter the price

The quantity parameter is a string - valid options are:

  • ‘1’ : ‘1’ button
  • ‘10’ : ‘10’ button
  • ‘100’ : ‘100’ button
  • Any other number : It will enter the quantity

Note

  • by The Mayor
  • Last Updated: 7 July 2016 by SlipperyPickle

Example:

  // To buy 10000 oak logs at 5% over the mid price
grandExchange.buyItem('Oak log', '+5', '10000');

  // To buy 10000 oak logs for 150gp each
grandExchange.buyItem('Oak log', '150', '10000');

  // As above, but waits up to 20 seconds for completion before collecting items
grandExchange.buyItem('Oak log', '150', '10000', true, 20000);

getPrice

TRSGrandExchange.getPrice(item: integer): integer;

Returns the current market price of any item in the Grand Exchange. The item parameter must be the item’s ID number.

IDs can be found on the Grand Exchange website at the end of the URL. For example, the ID in the below URL is 2150 (Swamp toad)

http://services.runescape.com/m=itemdb_rs/viewitem.ws?obj=2150

Note

  • by The Mayor
  • Last Updated: 16 July 2015 by The Mayor

Example:

var
  toadPrice: Integer;
begin
  toadPrice := grandExchange.getPrice(2150);  // The ID for Swamp toads
  profit := (toadPrice * toadsCollected);
end;