Results 1 to 13 of 13

Thread: chatbox.getXP

  1. #1
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default chatbox.getXP

    Just a little something until the devs come up with something better.

    Simba Code:
    function TRSChatBox.getXP: Integer;
    var
      b: TBox;
      s: String;
      tpa : TPointArray;
      atpa : T2DPointArray;
      i,cts,p: Integer;
    begin
      b := self.getBounds();
      b.edit(+(b.x2-b.x1)-140, +10, -5, -94);

      findColorsTolerance(tpa, 14013909, b, 4,colorSetting(2, 0.00, 0.00));

      if length(tpa) < 2 then
      begin
        print('chatBox.getXP(): No XP found', TDebug.SUB);
        Exit;
      end;

      atpa := tpa.cluster(5);

      b:= atpa.getbounds;
      b.edit(-2,-2,+2,+3);

      s:=Replace(tesseractgettext(b.x1,b.y1,b.x2,b.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);

      P := Pos('x', S);
      if P > 0 then
        Result := StrToIntDef(ExtractFromStr(Copy(s, P, Length(S)), Numbers), 0)
      else
        Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);

      print('chatBox.getXP(): XP found: ' + tostr(result), TDebug.SUB);
    end;

    put your xp bar round these parts:


    (in the larger red box)

    Then just call chatbox.getxp;

    ---- chatBox.getXP(): XP found: 870072
    Only works for 1 xp bar at a time (any xp bar you set)

    You can remove the drawboxes as you please!
    Last edited by Ashaman88; 12-24-2013 at 08:06 PM.

  2. #2
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    lovely ash !

    Creds to DannyRS for this wonderful sig!

  3. #3
    Join Date
    Dec 2013
    Posts
    95
    Mentioned
    2 Post(s)
    Quoted
    37 Post(s)

    Default

    I'm getting the following message when I try to call this from a test script (which just logs in, waits, and calls this).

    Exception in Script: Runtime error: "Access violation" at line 114, column 19 in file "C:\Simba\Includes\srl-6\lib\utilities\drawing.simba"
    Any help would be appreciated!

    EDIT: Is any particular height assumed for the chat box? Mine is smaller than default.
    Last edited by vwxz; 12-24-2013 at 03:27 AM.

  4. #4
    Join Date
    Mar 2013
    Location
    Freedomville.
    Posts
    155
    Mentioned
    2 Post(s)
    Quoted
    107 Post(s)

    Default

    Ooh, so I wasn't the only one who placed their XP bars there. Thanks!

  5. #5
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Quote Originally Posted by vwxz View Post
    I'm getting the following message when I try to call this from a test script (which just logs in, waits, and calls this).



    Any help would be appreciated!

    EDIT: Is any particular height assumed for the chat box? Mine is smaller than default.
    Yeah remove those drawing's unless you put SmartEnableDrawing := True;

  6. #6
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Thanks Ashaman, working great!

  7. #7
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default

    Quote Originally Posted by Ashaman88 View Post
    Just a little something until the devs come up with something better.

    Simba Code:
    function TRSChatBox.getXP: Integer;
    var
      b: TBox;
      s: String;
      tpa : TPointArray;
      atpa : T2DPointArray;
      i,cts,p: Integer;
    begin
      b := self.getBounds();
      b.edit(+(b.x2-b.x1)-140, +10, -5, -94);
      smartimage.drawbox(b,false,clred);

      cts := GetToleranceSpeed();
      SetColorToleranceSpeed(2);

      SetToleranceSpeed2Modifiers(0.00,0.00);

      findColorsTolerance(tpa, 14013909, b, 4);

      SetColorToleranceSpeed(CTS);
      SetToleranceSpeed2Modifiers(0.2,0.2);

      if length(tpa) < 2 then
      begin
        print('chatBox.getXP(): No XP found', TDebug.SUB);
        Exit;
      end;

      atpa := tpa.cluster(5);

      b:= atpa.getbounds;
      b.edit(-2,-2,+2,+2);

      smartimage.drawbox(b,false,clred);

      s:=tesseractgettext(b.x1,b.y1,b.x2,b.y2, FILTER_SMALL_CHARS);

      P := Pos('x', S);
      if P > 0 then
        Result := StrToIntDef(ExtractFromStr(Copy(s, P, Length(S)), Numbers), 0)
      else
        Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);

      print('chatBox.getXP(): XP found: ' + tostr(result), TDebug.SUB);
    end;

    put your xp bar round these parts:


    (in the larger red box)

    Then just call chatbox.getxp;



    Only works for 1 xp bar at a time (any xp bar you set)

    You can remove the drawboxes as you please!
    Nice work Ashaman!

    With SRL-6 you can make it slightly shorter, easier and safer for you - by using TColorSetting methods from color utilities (big thanks to @masterBB who added+tweaked them back then)

    Example:

    Simba Code:
    function TRSChatBox.getXP: Integer;
    var
      b: TBox;
      s: String;
      tpa : TPointArray;
      atpa : T2DPointArray;
      i,p: Integer;
    begin
      b := self.getBounds();
      b.edit(+(b.x2-b.x1)-140, +10, -5, -94);
      smartimage.drawbox(b,false,clred);

      findColorsTolerance(tpa, 14013909, b, 4, colorSetting(2, 0.00, 0.00));

      if length(tpa) < 2 then
      begin
        print('chatBox.getXP(): No XP found', TDebug.SUB);
        Exit;
      end;

      atpa := tpa.cluster(5);

      b:= atpa.getbounds;
      b.edit(-2,-2,+2,+2);

      smartimage.drawbox(b,false,clred);

      s:=tesseractgettext(b.x1,b.y1,b.x2,b.y2, FILTER_SMALL_CHARS);

      P := Pos('x', S);
      if P > 0 then
        Result := StrToIntDef(ExtractFromStr(Copy(s, P, Length(S)), Numbers), 0)
      else
        Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);

      print('chatBox.getXP(): XP found: ' + tostr(result), TDebug.SUB);
    end;

    So that way you don't have to worry about CTS stuff yourself at all.

    I even explained the way it works over here, but that topic is based on the old style that I suggested, before masterBB came up with a lot sexier way to do it - the way SRL uses it now!

    Basically the magic of it in a nutshell (updated from the topic above, to the SRL way):

    Code:
    function findColorTolerance(var x, y: Integer; color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): Boolean; overload;
    var
      cs: TColorSettings;
    begin
      // Step 1. Captures original (current) color settings in the begin to 'cs' variable
      cs.retrieve();
      // Step 2. Sets custom color settings (by settings) to Simba
      settings.apply();
      // Step 3. Performs the function, just like it should - with custom settings!
      Result := findColorTolerance(x, y, color, searchBox, tol);
      // Step 4. Restores the original color settings from 'cs' variable to Simba
      cs.apply();
    end;
    -Jani

  8. #8
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Quote Originally Posted by Janilabo View Post
    Nice work Ashaman!

    With SRL-6 you can make it slightly shorter, easier and safer for you - by using TColorSetting methods from color utilities (big thanks to @masterBB who added+tweaked them back then)

    Example:

    Simba Code:
    function TRSChatBox.getXP: Integer;
    var
      b: TBox;
      s: String;
      tpa : TPointArray;
      atpa : T2DPointArray;
      i,p: Integer;
    begin
      b := self.getBounds();
      b.edit(+(b.x2-b.x1)-140, +10, -5, -94);
      smartimage.drawbox(b,false,clred);

      findColorsTolerance(tpa, 14013909, b, 4, colorSetting(2, 0.00, 0.00));

      if length(tpa) < 2 then
      begin
        print('chatBox.getXP(): No XP found', TDebug.SUB);
        Exit;
      end;

      atpa := tpa.cluster(5);

      b:= atpa.getbounds;
      b.edit(-2,-2,+2,+2);

      smartimage.drawbox(b,false,clred);

      s:=tesseractgettext(b.x1,b.y1,b.x2,b.y2, FILTER_SMALL_CHARS);

      P := Pos('x', S);
      if P > 0 then
        Result := StrToIntDef(ExtractFromStr(Copy(s, P, Length(S)), Numbers), 0)
      else
        Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);

      print('chatBox.getXP(): XP found: ' + tostr(result), TDebug.SUB);
    end;

    So that way you don't have to worry about CTS stuff yourself at all.

    I even explained the way it works over here, but that topic is based on the old style that I suggested, before masterBB came up with a lot sexier way to do it - the way SRL uses it now!

    Basically the magic of it in a nutshell (updated from the topic above, to the SRL way):

    Code:
    function findColorTolerance(var x, y: Integer; color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): Boolean; overload;
    var
      cs: TColorSettings;
    begin
      // Step 1. Captures original (current) color settings in the begin to 'cs' variable
      cs.retrieve();
      // Step 2. Sets custom color settings (by settings) to Simba
      settings.apply();
      // Step 3. Performs the function, just like it should - with custom settings!
      Result := findColorTolerance(x, y, color, searchBox, tol);
      // Step 4. Restores the original color settings from 'cs' variable to Simba
      cs.apply();
    end;
    -Jani
    Yeah I think I had tried doing it the new way in another script but failed miserably haha. This makes sense now thanks man

  9. #9
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default

    Quote Originally Posted by Ashaman88 View Post
    Yeah I think I had tried doing it the new way in another script but failed miserably haha. This makes sense now thanks man
    Heh, it's all cool. Glad to hear I was able to explain it!

    In those cases when you are not sure exactly how it worked, you can always check out how it has been used in SRL so far, couple examples below:
    https://github.com/SRL/SRL-6/blob/d7...box.simba#L203
    https://github.com/SRL/SRL-6/blob/62...ban.simba#L620

    ..but yeah, it should be actually easier way than the old one is... Might look/feel a bit weird first, but once you get it rolling it's a nice time saver for you. Just takes some time to get used to it, for sure.

  10. #10
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Quote Originally Posted by Janilabo View Post
    Heh, it's all cool. Glad to hear I was able to explain it!

    In those cases when you are not sure exactly how it worked, you can always check out how it has been used in SRL so far, couple examples below:
    https://github.com/SRL/SRL-6/blob/d7...box.simba#L203
    https://github.com/SRL/SRL-6/blob/62...ban.simba#L620

    ..but yeah, it should be actually easier way than the old one is... Might look/feel a bit weird first, but once you get it rolling it's a nice time saver for you. Just takes some time to get used to it, for sure.
    Yeah I think I had tried basing off of an include function (that's how I first learned about it) but I must have been doing something crazy w/ the parameters and overload stuff

  11. #11
    Join Date
    Mar 2013
    Location
    Freedomville.
    Posts
    155
    Mentioned
    2 Post(s)
    Quoted
    107 Post(s)

    Default



    This happens occasionally.

  12. #12
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Quote Originally Posted by sdf View Post


    This happens occasionally.
    Strange any idea why the +xp dealio is so far to the left? Mine is normally right next to it. But I got's some idears

    Edit: sdf try the updated on in the OP
    Last edited by Ashaman88; 12-24-2013 at 08:06 PM.

  13. #13
    Join Date
    Mar 2013
    Location
    Freedomville.
    Posts
    155
    Mentioned
    2 Post(s)
    Quoted
    107 Post(s)

    Default

    Quote Originally Posted by Ashaman88 View Post
    Strange any idea why the +xp dealio is so far to the left? Mine is normally right next to it. But I got's some idears

    Edit: sdf try the updated on in the OP
    Works well

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
  •