# GrandExchange Methods to interact with the GrandExchange interface: ```{figure} ../../images/ge_interface.png ``` - - - ## EGEOfferProgress ```pascal EGEOfferProgress = 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.ReadItem ```pascal function TRSGrandExchangeSlot.ReadItem(): TRSItem; ``` Reads the item text in the offer slot. Example: ```pascal WriteLn GrandExchange.Slots[7].ReadItem(); ``` - - - ## TRSGrandExchangeSlot.Value ```pascal function 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.GetProgress ```pascal function TRSGrandExchangeSlot.GetProgress(): EGEOfferProgress; ``` Returns the slot {ref}`EGEOfferProgress`. Example: ```pascal WriteLn GrandExchange.Slots[2].GetProgress(); ``` - - - ## 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 variable Global {ref}`TRSGrandExchange` variable.