Results 1 to 16 of 16

Thread: TRSMinimap.getRunEnergy()

  1. #1
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default TRSMinimap.getRunEnergy()

    If you can do it, I will give you the SRL Master Cup
    Is this still valid? Who owes me a cup?
    Anyway, I'll check back in the morning.

    source
    Simba Code:
    (*
    getRunEnergy
    ------------

    .. code-block:: pascal

        function TRSMinimap.getRunEnergy(): integer;

    Returns the players current run energy. This isn't actually coded yet, because
    it is hard AF to do in colour accuratly. If you can do it, I will give you the
    SRL Master Cup :)

    .. note::

        - by - ????
        - Last Updated: -

    Example:

    .. code-block:: pascal

        if minimap.getRunEnergy() < 20 then
          minimap.enableRest();
    *)

    function TRSMinimap.getRunEnergy(): integer;
    begin
     writeLn('WARNING TRSMinimap.getRunEnergy(): Function hasn''t been coded yet!');
    end;

  2. #2
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    Is this still valid? Who owes me a cup?
    Anyway, I'll check back in the morning.

    source
    Simba Code:
    (*
    getRunEnergy
    ------------

    .. code-block:: pascal

        function TRSMinimap.getRunEnergy(): integer;

    Returns the players current run energy. This isn't actually coded yet, because
    it is hard AF to do in colour accuratly. If you can do it, I will give you the
    SRL Master Cup :)

    .. note::

        - by - ????
        - Last Updated: -

    Example:

    .. code-block:: pascal

        if minimap.getRunEnergy() < 20 then
          minimap.enableRest();
    *)

    function TRSMinimap.getRunEnergy(): integer;
    begin
     writeLn('WARNING TRSMinimap.getRunEnergy(): Function hasn''t been coded yet!');
    end;
    Can't you use tessaract? @Olly; could do it in like 5 seconds.

  3. #3
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    Can't you use tessaract? @Olly; could do it in like 5 seconds.
    Yeah that's what I did

  4. #4
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Umm...why did my version from like a year ago get deleted from pull requests? IIRC it worked correctly, just had to add a resting bitmap. If yours works with resting mode on then submit it - this one works for activated/deactivated non-rest only at the moment.

    Simba Code:
    (*
    TRSMinimap.getRunEnergy
    ~~~~~~~~~~~~~~~~~~~~~~~

    .. code-block:: pascal

        function TRSMinimap.getRunEnergy(): integer;

    Returns the players current run energy.

    .. note::

        - by Clarity
        - Last Updated: 12th October 2014 by Clarity

    Example:

    .. code-block:: pascal

        if (minimap.getRunEnergy() > 50) then
          minimap.toggleRun();
    *)

    function TRSMinimap.getRunEnergy(): integer;
    const
      RUN_DIGIT_1_TESSERACT_FILTER: TTesseractFilter = [5, 5, [true, 10, TM_Mean]];
      RUN_DIGIT_2_TESSERACT_FILTER: TTesseractFilter = [5, 5, [false, 35, TM_Mean]];
    var
      position, y, percBMP: integer;
      caps: TStringArray;
      searchBox1st, searchBox2nd: TBox;
    begin
        percBMP := BitmapFromString(8, 9, 'meJz7z/D/P6kIArBJMTAwkGwa3Ewq' +
            'qYe4AQBnyo9x');
        setTransparentColor(percBMP, 16711935);
        findBitmap(percBMP, position, y);
        freeBitmap(percBMP);
        case position of
          783: exit(100);
          780: begin
                 searchBox1st := IntToBox(766, 31, 771, 41);
                 searchBox2nd := IntToBox(773, 31, 779, 41);
                 setLength(caps, 2);
                 caps[0] := extractFromStr(tesseract_GetText(searchBox1st, RUN_DIGIT_1_TESSERACT_FILTER), numbers);
                 caps[1] := extractFromStr(tesseract_GetText(searchBox2nd, RUN_DIGIT_2_TESSERACT_FILTER), numbers);
                 result := (strToIntDef(caps[0] + caps[1], -1));
                 if (result < 10) then result := (result * 10);
               end;
          776: begin
                 searchBox1st := IntToBox(769, 31, 775, 41);
                 setLength(caps, 1);
                 caps[0] := extractFromStr(tesseract_GetText(searchBox1st, RUN_DIGIT_2_TESSERACT_FILTER), numbers);
                 result := (strToIntDef(caps[0], -1));
               end;
        end;
    end;

    https://github.com/SRL/SRL-6/pull/146
    Last edited by Clarity; 11-17-2015 at 03:04 PM.

  5. #5
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    Yeah that's what I did
    Oh, I thought this was a joke post. Where's the code?

  6. #6
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    Oh, I thought this was a joke post. Where's the code?
    It's still a mess and I have to fix one minor issue. I'll get to it in a few hours when I finish work.

  7. #7
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by Clarity View Post
    Umm...why did my version from like a year ago get deleted from pull requests? IIRC it worked correctly, just had to add a resting bitmap. If yours works with resting mode on then submit it - this one works for activated/deactivated non-rest only at the moment.

    Simba Code:
    (*
    TRSMinimap.getRunEnergy
    ~~~~~~~~~~~~~~~~~~~~~~~

    .. code-block:: pascal

        function TRSMinimap.getRunEnergy(): integer;

    Returns the players current run energy.

    .. note::

        - by Clarity
        - Last Updated: 12th October 2014 by Clarity

    Example:

    .. code-block:: pascal

        if (minimap.getRunEnergy() > 50) then
          minimap.toggleRun();
    *)

    function TRSMinimap.getRunEnergy(): integer;
    const
      RUN_DIGIT_1_TESSERACT_FILTER: TTesseractFilter = [5, 5, [true, 10, TM_Mean]];
      RUN_DIGIT_2_TESSERACT_FILTER: TTesseractFilter = [5, 5, [false, 35, TM_Mean]];
    var
      position, y, percBMP: integer;
      caps: TStringArray;
      searchBox1st, searchBox2nd: TBox;
    begin
        percBMP := BitmapFromString(8, 9, 'meJz7z/D/P6kIArBJMTAwkGwa3Ewq' +
            'qYe4AQBnyo9x');
        setTransparentColor(percBMP, 16711935);
        findBitmap(percBMP, position, y);
        freeBitmap(percBMP);
        case position of
          783: exit(100);
          780: begin
                 searchBox1st := IntToBox(766, 31, 771, 41);
                 searchBox2nd := IntToBox(773, 31, 779, 41);
                 setLength(caps, 2);
                 caps[0] := extractFromStr(tesseract_GetText(searchBox1st, RUN_DIGIT_1_TESSERACT_FILTER), numbers);
                 caps[1] := extractFromStr(tesseract_GetText(searchBox2nd, RUN_DIGIT_2_TESSERACT_FILTER), numbers);
                 result := (strToIntDef(caps[0] + caps[1], -1));
                 if (result < 10) then result := (result * 10);
               end;
          776: begin
                 searchBox1st := IntToBox(769, 31, 775, 41);
                 setLength(caps, 1);
                 caps[0] := extractFromStr(tesseract_GetText(searchBox1st, RUN_DIGIT_2_TESSERACT_FILTER), numbers);
                 result := (strToIntDef(caps[0], -1));
               end;
        end;
    end;

    https://github.com/SRL/SRL-6/pull/146
    I basically did the same thing, but without bitmaps, ie used the percent sign to limit the searchbox for tesseract

  8. #8
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by Clarity View Post
    Umm...why did my version from like a year ago get deleted from pull requests?
    Quote Originally Posted by Justin
    i think the only reason ... is: Clarity is a shit scripter
    This

  9. #9
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by Clarity View Post
    my version
    That was my first thought when I saw the thread title. "Clarity's pull request finally got merged??"
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  10. #10
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    This seems to work while resting, walking, running, resting with run activated...
    delphi Code:
    program new;
    {$I SRL-6/SRL.simba}

    function FindColorsTolBitmap(bmp:Int32; var TPA:TPointArray; color:Int32; B:TBox; tol:Int32): Boolean;
    var oldT,T:Int32;
    begin
      oldT := GetImageTarget();
      T := SetTargetBitmap(bmp);
      SetImageTarget(T);
      Result := FindColorsTolerance(TPA, color, B.x1,B.y1,B.x2,B.y2, tol);
      SetImageTarget(oldT);
      FreeTarget(T);
    end;

    function TRSMinimap.GetRunEnergy(): Int32; override;
    var
      w,h,bmp,src:Int32;
      TPA:TPointArray;
      tmpVar:String;
    begin
      try
        src := BitmapFromClient(762,31,790,38);
        bmp := CreateBitmap(50,25);
        FastDrawTransparent(5,5,src,bmp);
        FreeBitmap(src);

        GetBitmapSize(bmp,w,h);
        W *= 6;
        H *= 6;
        ResizeBitmapEx(bmp,RM_Bilinear,w,h);
        FindColorsTolBitmap(bmp, TPA, $FFFFFF, [0,0,w-1,h-1], Trunc(441.6*0.4));
        FastDrawClear(bmp, 0);
        DrawTPABitmap(bmp, TPA, $FFFFFF);
        tmpVar := Tesseract_GetText(bmp, TESS_WHITELIST_NUMBERS+'%');
        Result := StrToIntDef(ExtractFromStr(tmpVar, NUMBERS), -1);
      finally
        FreeBitmap(bmp);
      end;
    end;

    *waits for cup*
    Last edited by slacky; 02-11-2016 at 08:42 PM.
    !No priv. messages please

  11. #11
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    *waits for cup*
    you win. Here is you santa:

  12. #12
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    This
    I've always been horrible, I don't know how I get away with it.

    Quote Originally Posted by slacky View Post
    This seems to work while resting, walking, running, resting with run activated...

    *waits for cup*
    Awesome!

  13. #13
    Join Date
    Feb 2013
    Location
    The Boonies
    Posts
    203
    Mentioned
    9 Post(s)
    Quoted
    70 Post(s)

    Default

    Simba Code:
    function minimap.getRunEnergy (): integer;
    begin
      result := lookAtEnergyThingAndConvertToUsefulInformation;
    end;

    I am the master scripter. Let the worshipping begin.

  14. #14
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    Can't you use tessaract? @Olly; could do it in like 5 seconds.
    I remember when he tried, pretty much got it to the same state as other peoples attemts ;P
    Last edited by slacky; 11-17-2015 at 08:01 PM.
    !No priv. messages please

  15. #15
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    I remember when he tried, pretty much got it to the same state as other peoples attemts ;P
    Oh. Well take your cup and get out of here!

  16. #16
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    Oh. Well take your cup and get out of here!
    Will do!
    !No priv. messages please

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
  •