Results 1 to 22 of 22

Thread: [OSR][REFLECTION] Grand Exchange Include

  1. #1
    Join Date
    Mar 2012
    Posts
    107
    Mentioned
    2 Post(s)
    Quoted
    49 Post(s)

    Post [OSR][REFLECTION] Grand Exchange Include

    Here's the include I've been working on the past few hours/days.

    Simba Code:
    type
      TSlotInterface = record
        Bounds:Tbox;
        EmptySlot:Integer;
      end;
      TOfferInterface = record
        bounds:Tbox;
      end;
      TGrandExchange = Record
        Offer:TOfferInterface;
        Slot:TSlotInterface;
      end;

    var
      GrandExchange:TGrandExchange;

    function TGrandExchange.IsUp: Boolean;
    var
    ParentWidget, ChildWidget: TReflectWidget;

    begin
      ParentWidget.GetWidget(465, 2);
      ChildWidget.GetChild(ParentWidget, 1);

      if Pos('grand', LowerCase(ChildWidget.GetText)) then
        Result:= true;
      ChildWidget.Free;
      ParentWidget.Free;
    end;
    function TOfferInterface.OfferScreen:Boolean;
    var
      a, b:TReflectWidget;
    begin
      if a.Exists(465, 2) then
        begin
          a.GetWidget(465, 2);
          b.GetChild(a, 1);
          if Pos('offer', LowerCase(b.gettext)) then
            Result := True;
        end;
      a.free;
      b.free;
    end;

    procedure TSlotInterface.ClickBuy(Slot:integer);
    var
    a, b:TReflectWidget;
    begin
      A.GetWidget(465, Slot+6);
      B.GetChild(A, 0);
      Reflect.Mouse.Move(Point(
      RandomRange(b.GetBounds.X1, b.GetBounds.X2),
      RandomRange(b.GetBounds.y1, b.GetBounds.y2)
      ), 0, 0);
      Reflect.Mouse.Click(mouse_left);
      Wait(RandomRange(400,750));
      A.free;
      B.free;
    end;
    procedure TSlotInterface.ClickSell(Slot:integer);
    var
      a, b:TReflectWidget;

    begin
      A.GetWidget(465, Slot+6);
      B.GetChild(A, 1);
      Reflect.Mouse.Move(Point(
      RandomRange(b.GetBounds.X1, b.GetBounds.X2),
      RandomRange(b.GetBounds.y1, b.GetBounds.y2)
      ), 0, 0);
      Reflect.Mouse.Click(mouse_left);
      A.free;
      B.free;
    end;
    procedure TOfferInterface.ClickConfirm;
    var
      a, b:TReflectWidget;
    begin
      a.GetWidget(465, 24);
      b.GetChild(a, 54);
      Reflect.Mouse.Move(Point(
      RandomRange(b.GetBounds.X1, b.GetBounds.X2),
      RandomRange(b.GetBounds.y1, b.GetBounds.y2)
      ), 0, 0);
      Reflect.Mouse.Click(mouse_left);
      a.free;
      b.free;

    end;

    procedure TOfferInterface.SetPrice(amount:string);
    var
      a, b:TReflectWidget;
    begin
      a.GetWidget(465, 24);
      b.GetChild(a, 12);
      Reflect.Mouse.Move(Point(
      RandomRange(b.GetBounds.X1, b.GetBounds.X2),
      RandomRange(b.GetBounds.y1, b.GetBounds.y2)
      ), 0, 0);
      Reflect.Mouse.Click(mouse_left);
      Wait(RandomRange(500, 1000));
      Reflect.Keyboard.TypeSend(amount, true);

      a.free;
      b.free;

    end;
    procedure TOfferInterface.SetQuantity(amount:String);
    var
      a, b:TReflectWidget;
    begin
      a.GetWidget(465, 24);
      b.GetChild(a, 7);
      Reflect.Mouse.Move(Point(
      RandomRange(b.GetBounds.X1, b.GetBounds.X2),
      RandomRange(b.GetBounds.y1, b.GetBounds.y2)
      ), 0, 0);
      Reflect.Mouse.Click(mouse_left);
      Wait(RandomRange(500, 1000));
      Reflect.Keyboard.TypeSend(amount, true);
      a.free;
      b.free;
    end;


    function TSlotInterface.OfferType(Slot: Integer):String;
    var
      a, b: TReflectWidget;
    begin
        a.GetWidget(465, (Slot+6));
        b.GetChild(a, 16);
        Result := b.GetText;
        b.Free;
        a.Free;
    end;


    function TSlotInterface.GetItemFromSlot(Slot:Integer):String;
    var
      a,b:TReflectWidget;
    begin
      a.GetWidget(465, Slot+6);
      b.GetChild(a, 19);
      Result:= b.GetText;
      a.free;
      b.free;
    end;

    function TOfferInterface.ItemPrice:Integer; //Returns the price of the item
    var
    a, b:TReflectWidget;
    begin
    a.GetWidget(465, 15);
    b.GetChild(a, 25);
    Result := StrToInt(replace(b.GetText, ',', '', [rfReplaceAll]));
    a.free;
    b.free;

    end;

    function TOfferInterface.AmountSold:String //Returns the total amount sold so far.
    var
      a, b:TReflectWidget;
      c, d:String;
    begin
      a.GetWidget(465, 22);
      b.GetChild(a, 1);
      c := Between('sold', 'for', b.GetText);
      d := Between('>', '<', c);
      d := replace(d, ',', '', [rfReplaceAll]);
      Result := d;
      a.free;
      b.free;

    end;
    function TOfferInterface.AmountBought:Integer;//Returns the total amount bought so far.
    var
      a, b:TReflectWidget;
      c, d:String;
    begin
      a.GetWidget(465, 22);
      b.Getchild(a, 1);
      c:= Between('bought', 'price', b.GetText);
      d:= Between('>','<', c);
      Result := StrToInt(replace(d, ',', '', [rfReplaceAll]));
      a.free;
      b.free;
    end;

    function TOfferInterface.OfferItem:String; //Returns the item being being bought or sold in the offer screen.
    var
    a, b:TReflectWidget;
    begin
      a.GetWidget(465, 24);
      b.GetChild(a, 25);
      Result:= b.GetText;
      a.free;
      b.free;
    end;

    function TGrandExchange.Collect:Boolean;//Clicks the collect button on the GEInterface
    var                        //NOT the collect boxes in the offer screen.
      a,b:TReflectWidget;
    begin
      a.GetWidget(465, 6);
      b.GetChild(a, 1);
      if Pos('collect', Lowercase(b.GetText)) then
        begin
          Result:= true;
          Reflect.Mouse.Move(Point(
          RandomRange(b.GetBounds.X1, b.GetBounds.X2),
          RandomRange(b.GetBounds.y1, b.GetBounds.y2)
          ), 0, 0);
          Reflect.Mouse.Click(mouse_left);
        end;
      a.free;
      b.free;

    end;



    function TOfferInterface.TotalPrice:String; //Returns the total that the items sold/bought for so far.
    var
      a, b:TReflectWidget;
      c, d:String;
    begin
      a.GetWidget(465, 22);
      b.Getchild(a, 1);
      c:= Between('price', 'coins', b.GetText);
      d:= Between('>','<', c);
      Result := replace(d, ',', '', [rfReplaceAll]);
      a.free;
      b.free;
    end;
    function TSlotInterface.ClickEmptySlot(buy, sell:Boolean):Boolean;
    var
      a,b:TReflectWidget;
      i:Integer;
    begin
     if a.Exists(465, i) then
      for i:= 7 to 14 do
        begin
        a.GetWidget(465, i);
        b.GetChild(a, 16);
        if Pos('Empty', b.GetText) then
          begin
            if buy then
              begin
                TSlotInterface.ClickBuy(i-6);
                Result:= True;
                a.free;
                b.free;
                Exit;
              end;
            if sell then
              begin
                TSlotInterface.ClickSell(i-6);
                Result:= True;
                a.free;
                b.free;
                Exit;
              end;
          end
        else
          Continue;
        end
    end;

    function TSlotInterface.FindEmpty:Integer;
    var
      a,b:TReflectWidget;
      i:Integer;
    begin
     if a.Exists(465, i) then
      for i:= 7 to 14 do
        begin
        a.GetWidget(465, i);
        b.GetChild(a, 16);
        if Pos('Empty', b.GetText) then
          Result := i;
        end
    end;

    function TGrandExchange.AbortSlot(Slot:integer):Boolean;
    var
      a, b:TReflectWidget;
    begin
      A.GetWidget(465, Slot+6);
      B.GetChild(A, 2);
      Reflect.Mouse.Move(Point(
      RandomRange(b.GetBounds.X1, b.GetBounds.X2),
      RandomRange(b.GetBounds.y1, b.GetBounds.y2)
      ), 0, 0);
      Reflect.Mouse.Click(mouse_right);
      Wait(RandomRange(254,653));
      Result := Reflect.Text.ChooseOption('Abort offer');
      Wait(RandomRange(340, 400));
      self.Collect;
      a.free;
      b.free;
    end;

    procedure TOfferInterface.ClickChooseItem;
    var
      a,b:TReflectWidget;
      p:TPoint;
    begin
      a.GetWidget(465, 24);
      b.GetChild(a, 0);
      p.x := RandomRange(b.GetBounds.X1, b.GetBounds.X2);
      p.y := RandomRange(b.GetBounds.Y1, b.GetBounds.Y2);
      Reflect.Mouse.Move(p, 0, 0);
      Reflect.Mouse.Click(mouse_left);
      a.free;
      b.free;
    end;

    function TOfferInterface.IsSearch:Boolean;
    var
    a, b:TReflectWidget;
    begin
     a.GetWidget(162,38);
     Result := a.HasChild;
    end;

    procedure TOfferInterface.Search(item:string);
    var
      a,b:TReflectWidget;
      i:Integer;
      t:TReflectTimer;
      pt:TPoint;
    begin
      if not self.OfferScreen then
        exit;
      if not self.isSearch then
        self.ClickChooseItem;
      Wait(RandomRange(250, 650));
      Reflect.KeyBoard.TypeSend(item);
      Wait(RandomRange(250, 650));
      a.GetWidget(162,38);
      b.GetChild(a, 1);
      pt.x := RandomRange(b.GetBounds.X1, b.GetBounds.X2);
      pt.y := RandomRange(b.GetBounds.Y1, b.GetBounds.Y2);
      Reflect.Mouse.Move(pt, 0, 0);
      Reflect.Mouse.Click(mouse_left);
      a.free;
      b.free;
    end;

    function TOfferInterface.GetQuantity:Integer;
    var
      a,b:TReflectWidget;
      s1,s2:String;
      i:String;
    begin
      a.GetWidget(465, 15);
      b.GetChild(a, 18);
      s1 := replace(b.getText, ',','', [rfReplaceAll]);
      Result := StrToInt(Trim(replace(b.getText, ',','', [rfReplaceAll])));
      a.free;
      b.free;
    end;

    function TOfferInterface.CompleteBuy:Boolean;
    begin
      Result := (self.GetQuantity = self.AmountBought);
    end;
    function TOfferInterface.CompleteSold:Boolean;
    begin
      Result := (StrToInt(self.AmountSold) = self.GetQuantity);
    end;

    function TofferInterface.OfferType:String;
    var
      a, b:TReflectWidget;
    begin
      a.GetWidget(465, 15);
      b.GetChild(a, 4);
      Result := b.getText;
      a.free;
      b.free;
    end;
    function TOfferInterface.Complete:Boolean;
    begin
      if (self.OfferType = 'Buy offer') then
        Result := self.CompleteBuy;
      if (self.offertype = 'Sell offer') then
        Result := self.CompleteSold;
    end;

    Place this in your Includes inside of a folder called GrandExchange.

    From there you can use it like this in a script.





    If you have any questions then please feel free to ask!


    LIST OF PROCEDURES/FUNCTIONS

    Simba Code:
    function GrandExchange.IsUp: Boolean; //Tells us whether the Grand Exchange interface is up.

    function GrandExchange.Offer.OfferScreen:Boolean; //Tells us if we are at the offer screen.

    procedure GrandExchange.Slot.ClickBuy(Slot:integer); //Clicks buy on the corresponding slot.

    procedure GrandExchange.Slot.ClickSell(Slot:integer); //Clicks sell on the corresponding slot.

    procedure GrandExchange.Offer.ClickConfirm; //Clicks confirm.

    procedure GrandExchange.Offer.SetPrice(amount:string); //Sets the price of the offer.

    procedure GrandExchange.Offer.SetQuantity(amount:String); //Sets the quantity for the offer.

    function GrandExchange.Slot.OfferType(Slot: Integer):String;  //Returns a string of the slot type. It is either 'Buy offer','Sell offer', or 'Empty'.

    function GrandExchange.Slot.GetItemFromSlot(Slot:Integer):String; //Returns the item in the corresponding slot.

    function GrandExchange.Offer.ItemPrice:Integer; //Returns the price of the item

    function GrandExchange.Offer.AmountSold:String //Returns the total amount sold so far.

    function GrandExchange.Offer.AmountBought:Integer;//Returns the total amount bought so far.

    function GrandExchange.Offer.OfferItem:String; //Returns the item being being bought or sold in the offer screen.

    function GrandExchange.Collect:Boolean; //Clicks the collect button on the Grand Exchange Interface

    function GrandExchange.Offer.TotalPrice:String; //Returns the total that the items sold/bought for so far.

    function GrandExchange.Slot.ClickEmptySlot(buy, sell:Boolean):Boolean; //Very simple clicks buy OR sell on an empty slot. Make sure if one is set to true the other is set to false.

    function GrandExchange.Slot.FindEmpty:Integer; //Returns the slot number of an empty slot.

    function GrandExchange.AbortSlot(Slot:integer):Boolean;  //Aborts the slot and then collects the items.

    procedure GrandExchange.Offer.ClickChooseItem; //Clicks the Choose item box in the Offer screen, used in another function to check if we are searching for an item.

    function GrandExchange.Offer.IsSearch:Boolean; //Returns if we are able to search, sometimes the search in the chat doesnt come up. Failsafe.

    procedure GrandExchange.Offer.Search(item:string);//Searchs for an item and then clicks the item in the chat.

    function GrandExchange.Offer.GetQuantity:Integer; //Returns the quantity being bought, NOT The quantity that sold.

    function GrandExchange.Offer.OfferType:String; //Returns the offer type of the offer.

    function GrandExchange.Offer.Complete:Boolean; //Returns true if the offer has completed.

    Get the Attachment here:GrandExchange.simba
    Last edited by One Kid; 01-02-2016 at 12:02 AM.

  2. #2
    Join Date
    Sep 2014
    Location
    C:\Simba\
    Posts
    565
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    Damn that is impressive. Keep up the good work!
    Feel free to ask me any questions, I will do my best to answer them!

    Previously known as YouPee.

  3. #3
    Join Date
    Sep 2014
    Posts
    447
    Mentioned
    10 Post(s)
    Quoted
    203 Post(s)

    Default

    It's great to see you following up! Best of luck, it's looking great!

  4. #4
    Join Date
    Mar 2012
    Posts
    107
    Mentioned
    2 Post(s)
    Quoted
    49 Post(s)

    Default

    Quote Originally Posted by yourule97 View Post
    It's great to see you following up! Best of luck, it's looking great!
    Quote Originally Posted by Joopi View Post
    Damn that is impressive. Keep up the good work!
    Thanks guys.

    There are still some minor tweaks coming in, but the functionality is there.

  5. #5
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    I am impressed; Your two steps ahead of me. =D

    I have been up all night; i will try squeeze a nap in and see what i can make of this! very promising.

    Rep+

    <------------------>



  6. #6
    Join Date
    Mar 2012
    Posts
    107
    Mentioned
    2 Post(s)
    Quoted
    49 Post(s)

    Default

    Quote Originally Posted by AFools View Post
    I am impressed; Your two steps ahead of me. =D

    I have been up all night; i will try squeeze a nap in and see what i can make of this! very promising.

    Rep+
    Thank you! Let me know if you need any help.

  7. #7
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Nice work. I guess you now need buy and sell

  8. #8
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    Quote Originally Posted by The Simba Noob View Post
    Nice work. I guess you now need buy and sell
    ?????



    procedure GrandExchange.Slot.ClickBuy(Slot:integer); //Clicks buy on the corresponding slot.

    procedure GrandExchange.Slot.ClickSell(Slot:integer); //Clicks sell on the corresponding slot.

    I have yet to test the functionality of these.

    <------------------>



  9. #9
    Join Date
    Mar 2012
    Posts
    107
    Mentioned
    2 Post(s)
    Quoted
    49 Post(s)

    Default

    No you do not need buy and sell. That functionality is to be made by the scripter. Because price and other things like quantity need to be set and only the scripter will know what exactly they are trying to do.


    Example of how to buy.

    Simba Code:
    GrandExchange.Slot.ClickBuy(5);
      GrandExchange.Offer.Search('Law Rune');
      GrandExchange.Offer.ClickConfirm;
      Wait(250);
      GrandExchange.Collect;
    Last edited by One Kid; 01-02-2016 at 04:23 PM.

  10. #10
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Quote Originally Posted by AFools View Post
    ?????



    procedure GrandExchange.Slot.ClickBuy(Slot:integer); //Clicks buy on the corresponding slot.

    procedure GrandExchange.Slot.ClickSell(Slot:integer); //Clicks sell on the corresponding slot.

    I have yet to test the functionality of these.
    Quote Originally Posted by One Kid View Post
    No you do not need buy and sell. That functionality is to be made by the scripter. Because price and other things like quantity need to be set and only the scripter will know what exactly they are trying to do.


    Example of how to buy.

    Simba Code:
    GrandExchange.Slot.ClickBuy(5);
      GrandExchange.Offer.Search('Law Rune');
      GrandExchange.Offer.ClickConfirm;
      Wait(250);
      GrandExchange.Collect;
    Oh, I guess you could do it like that. I was thinking like GrandExchange.Buy('Law Rune', 300, 10000); to turn those 5 lines into 1 (like the srl one).

  11. #11
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    Quote Originally Posted by The Simba Noob View Post
    Oh, I guess you could do it like that. I was thinking like GrandExchange.Buy('Law Rune', 300, 10000); to turn those 5 lines into 1 (like the srl one).
    I don't want to take any credit from 'One Kid' because this is primarily his project; but behind the scene we are now working together on the overall "run-loop" in regards to functionality of the widgets he has made.

    So far the script places buy/sell order - with the desired quantity; I have just woken up and will see if i can get this completely functioning by the end of the day.

    Then comes consolidating the widgets into a 'concise-usable function'

    <------------------>



  12. #12
    Join Date
    Mar 2012
    Posts
    107
    Mentioned
    2 Post(s)
    Quoted
    49 Post(s)

    Default

    Quote Originally Posted by The Simba Noob View Post
    Oh, I guess you could do it like that. I was thinking like GrandExchange.Buy('Law Rune', 300, 10000); to turn those 5 lines into 1 (like the srl one).
    Well then, I suppose I will put out an update that does just that. I'll make it a function that returns true if the offer is placed, or false if it isn't. For both sell or buy.

  13. #13
    Join Date
    Jan 2016
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Looks amazing.

  14. #14
    Join Date
    Mar 2012
    Posts
    107
    Mentioned
    2 Post(s)
    Quoted
    49 Post(s)

    Default

    Quote Originally Posted by Vizual View Post
    Looks amazing.
    Thank you! Glad you like it.

  15. #15
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Quote Originally Posted by One Kid View Post
    Thank you! Glad you like it.
    He doesn't actually like it. He probably couldn't care less. He was just spamming to get a post count of 10 so he could PM

  16. #16
    Join Date
    Mar 2012
    Posts
    107
    Mentioned
    2 Post(s)
    Quoted
    49 Post(s)

    Default

    Quote Originally Posted by The Simba Noob View Post
    He doesn't actually like it. He probably couldn't care less. He was just spamming to get a post count of 10 so he could PM
    Doh! lol that makes sense. I'd like to think he does :P

  17. #17
    Join Date
    Apr 2012
    Posts
    35
    Mentioned
    1 Post(s)
    Quoted
    8 Post(s)

    Default

    Looks awesome. I think reflection widgets are outdated at the moment so that would be the only hickup :/ It seems as though the hooks for the objects are updated much more often than the widgets.

  18. #18
    Join Date
    Jan 2014
    Posts
    51
    Mentioned
    5 Post(s)
    Quoted
    24 Post(s)

    Default

    Quote Originally Posted by k9thebeast View Post
    Looks awesome. I think reflection widgets are outdated at the moment so that would be the only hickup :/ It seems as though the hooks for the objects are updated much more often than the widgets.
    I was just in the middle of making this for one of my scripts... I didn't even notice this existed, awesome work man.

  19. #19
    Join Date
    Mar 2012
    Posts
    107
    Mentioned
    2 Post(s)
    Quoted
    49 Post(s)

    Default

    Quote Originally Posted by mudda_fudda View Post
    I was just in the middle of making this for one of my scripts... I didn't even notice this existed, awesome work man.
    Thanks. I haven't really messed with it in awhile. If you have any questions feel free to message me.

  20. #20
    Join Date
    Aug 2015
    Posts
    16
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    I read all and i think these codes will buy items on g.e at middle price. Will you give us any option to buy any item for %5 more of normal price? Thanks.

  21. #21
    Join Date
    Mar 2012
    Posts
    107
    Mentioned
    2 Post(s)
    Quoted
    49 Post(s)

    Default

    Quote Originally Posted by maikelpro99 View Post
    I read all and i think these codes will buy items on g.e at middle price. Will you give us any option to buy any item for %5 more of normal price? Thanks.

    When You've already searched for your item do this.
    Simba Code:
    GrandExchange.Offer.SetPrice(IntToStr(Round(GrandExchange.Offer.ItemPrice*1.05)));

  22. #22
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    TOfferInterface = record
    bounds:Tbox;
    end;

    Might aswell not be a record, or could be changed to

    TOfferInterface = TBox;

    for organization purposes I guess

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •