# GrandExchange Methods to interact with the GrandExchange interface: ```{figure} ../../images/ge_interface.png ``` The {ref}`GrandExchange` is a very complex interface, probably the most complex available in OldSchool RuneScape and for that reason, the functionality to fully interact with it is split into multiple files and records: - {ref}`GrandExchange`, the main grand exchange screen and what this page is about. - {ref}`GrandExchangeHistory`, the history screen of the grand exchange. - {ref}`GrandExchangeChat`, the chat interface of the grand exchange when you are setting up a buy offer. - {ref}`GrandExchangeOffer`, the screen of the grand exchange where you view or setup a new offer. - - - ## EGEOfferStatus ```pascal EGEOfferStatus = enum(NONE, PROGRESSING, COMPLETED, ABORTED); ``` Enum to represent the Grand Exchange offer slot states. - - - ## EGESlotType ```pascal EGESlotType = enum(EMPTY, SELL, BUY); ``` Enum to represent the type of Grand Exchange offer slot. - - - ## TRSGrandExchangeSlot Record that represents a slot in the {ref}`GrandExchange` interface. When you want to interact with a Grand Exchange slot you should do it through the `TRSGrandExchange.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 `TRSGrandExchangeSlot` has to offer are you can use this short script: ```pascal {$I WaspLib/osrs.simba} var img: TImage; slot: TRSGrandExchangeSlot; 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. ``` ```{figure} ../../images/ge_slots.png ``` - - - ## TRSGrandExchangeSlot ```pascal function TRSGrandExchangeSlot.GetType(): EGESlotType; ``` Returns the {ref}`EGESlotType` of the slot. This also sets the `TRSGrandExchangeSlot.Typ` to the result in case you want to access it later without calling this. WaspLib will also try to keep `TRSGrandExchangeSlot.Typ` updated when you interact with the `GrandExchange` but it cannot track things a user might do manually. Example: ```pascal WriteLn GrandExchange.Slots[2].GetType(); ``` - - - ## TRSGrandExchangeSlot.Contains ```pascal function TRSGrandExchangeSlot.Contains(item: TRSItem): Boolean; ``` Returns the {ref}`TRSItem` of the slot. If the slot is empty an empty string is returned. Example: ```pascal WriteLn GrandExchange.Slots[0].Contains('Abyssal whip'); ``` - - - ## TRSGrandExchangeSlot.Discover ```pascal function TRSGrandExchangeSlot.Discover(): TRSItemArray; ``` Uses item discover to return a {ref}`TRSItemArray` of the possible items in the slot. If the slot is empty an empty array is returned. Example: ```pascal WriteLn GrandExchange.Slots[5].Discover(); ``` - - - ## TRSGrandExchangeSlot.Item ```pascal property TRSGrandExchangeSlot.Item: TRSItem; ``` Reads the item text in the offer slot. Example: ```pascal WriteLn GrandExchange.Slots[7].Item; ``` - - - ## TRSGrandExchangeSlot.Value ```pascal property TRSGrandExchangeSlot.Value: Integer; ``` Reads the value text in the offer slot and returns it as an `Integer`. Example: ```pascal WriteLn GrandExchange.Slots[3].Value; ``` - - - ## TRSGrandExchangeSlot.Quantity ```pascal property TRSGrandExchangeSlot.Quantity: Integer; ``` Returns the quantity text in the offer slot as an `Integer`. Example: ```pascal WriteLn GrandExchange.Slots[4].Quantity; ``` - - - ## TRSGrandExchangeSlot.TotalValue ```pascal property TRSGrandExchangeSlot.TotalValue: Integer; ``` Returns the total value of the offer slot. Taking into account the Grand Exchange tax for sell offers. Example: ```pascal WriteLn GrandExchange.Slots[5].TotalValue; ``` - - - ## TRSGrandExchangeSlot.Status ```pascal property TRSGrandExchangeSlot.Status: EGEOfferStatus; ``` Returns the slot {ref}`EGEOfferStatus` status. Example: ```pascal WriteLn GrandExchange.Slots[2].Status; ``` - - - ## TRSGrandExchangeSlot.Progress ```pascal property TRSGrandExchangeSlot.Progress: Integer; ``` Returns the progress percentage of the slot. Example: ```pascal WriteLn GrandExchange.Slots[2].Progress; ``` - - - ## TRSGrandExchangeSlot.Open ```pascal function TRSGrandExchangeSlot.Open(): Boolean; ``` Attempts to open the {ref}`GrandExchangeOffer` status screen of an existing offer. Example: ```pascal WriteLn GrandExchange.Slots[1].Open(); ``` - - - ## TRSGrandExchangeSlot.Buy ```pascal function TRSGrandExchangeSlot.Buy(): Boolean; ``` Attempts to open the {ref}`GrandExchangeOffer` screen with the buy button. Example: ```pascal WriteLn GrandExchange.Slots[2].Buy(); ``` - - - ## TRSGrandExchangeSlot.Sell ```pascal function TRSGrandExchangeSlot.Sell(): Boolean; ``` Attempts to open the {ref}`GrandExchangeOffer` screen with the sell button. Example: ```pascal WriteLn GrandExchange.Slots[2].Sell(); ``` - - - ## TRSGrandExchangeSlot.Abort ```pascal function TRSGrandExchangeSlot.Abort(): Boolean; ``` Attempts to abort an ongoing offer in the slot. Example: ```pascal WriteLn GrandExchange.Slots[3].Abort(); ``` - - - ## TRSGrandExchange Record responsible to handle the {ref}`GrandExchange` interface. - - - ## GrandExchange.SetupInterface ```pascal procedure TRSGrandExchange.SetupInterface(); ``` Internal method used to setup the {ref}`TRSGrandExchange` coordinates. This is automatically called for you on the {ref}`GrandExchange variable`. - - - ## GrandExchange.IsOpen ```pascal function TRSGrandExchange.IsOpen(): Boolean; ``` Returns true if the Grand Exchange is open. Example: ```pascal WriteLn GrandExchange.IsOpen(); ``` - - - ## GrandExchange.WaitOpen ```pascal function TRSGrandExchange.WaitOpen(time: Integer; interval: Integer = -1): Boolean; ``` Returns true if the Grand Exchange is open within `time` milliseconds. ## Example: ```pascal WriteLn GrandExchange.WaitOpen(); ``` - - - ## GrandExchange.Close ```pascal function TRSGrandExchange.Close(escape: Boolean): Boolean; function TRSGrandExchange.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: ```pascal WriteLn GrandExchange.Close(); ``` - - - ## GrandExchange.GetEmptySlots ```pascal function TRSGrandExchange.GetEmptySlots(): TRSGrandExchangeSlotArray; ``` Returns a `TRSGrandExchangeSlotArray` of the empty slots available. Example: ```pascal {$I WaspLib/osrs.simba} var img: TImage; slot: TRSGrandExchangeSlot; begin img := Target.GetImage(); img.DrawColor := $00FFFF; for slot in GrandExchange.GetEmptySlots() do img.DrawBox(slot.Bounds); img.Show(); end. ``` ```{figure} ../../images/ge_emptyslots.png ``` - - - ## GrandExchange.IndexOfEmptySlot ```pascal function TRSGrandExchange.IndexOfEmptySlot(): Integer; ``` Returns the index of the first empty slot available. Example: ```pascal WriteLn GrandExchange.IndexOfEmptySlot(); ``` - - - ## GrandExchange.GetEmptySlot ```pascal function TRSGrandExchange.GetEmptySlot(): TRSGrandExchangeSlot; ``` Returns a `TRSGrandExchangeSlot` that is empty. Example: ```pascal {$I WaspLib/osrs.simba} begin ShowOnTarget(GrandExchange.GetEmptySlot().Bounds); end. ``` ```{figure} ../../images/ge_emptyslot.png ``` - - - ## TRSGrandExchange.Collect ```pascal function TRSGrandExchange.Collect(): Boolean; ``` Attempts to Collect from the Grand Exchange. In case of failure, returns False. Example: ```pascal WriteLn GrandExchange.Collect(); ``` - - - ## GrandExchange variable Global {ref}`TRSGrandExchange` variable.