Results 1 to 3 of 3

Thread: Makedo GetRunEnergy Function

  1. #1
    Join Date
    Oct 2011
    Posts
    100
    Mentioned
    1 Post(s)
    Quoted
    25 Post(s)

    Default Makedo GetRunEnergy Function

    Hey guys, I have just begun writing an updated air runecrafter and found that the getrunenergy function was non-existent (it has not yet been updated). I have created a make-do function which can be used to approximate it pretty accurately (within 5%). Here is the function if it would be of use to anyone:

    Code:
    // GET THE RUN ENERGY PERCENTAGE
    function GetRunEnergy: Integer;
    var
      TPA1, TPA2 : TPointArray;
      k, p, h, c, percApprox : integer;
      j : TBox;
    begin
      findColorsTolerance(TPA1, 1126294,761, 21, 791, 50, 30); // Creates a TPointArray of matching points in the run icon area
      //smartImage.debugTPA(TPA1);
      j := GetTPABounds(TPA1); // Convert the TPArray bounds to a TBox
      c := j.getHeight(); // Find the height of the TBox
      percApprox := Round(3.846*c); // Thus, find the percentage- 100% was ~26
      WriteLn(percApprox);  // Print the approximate percentage
      Result := percApprox; // Make the result equal to the percentage
    end;
    I understand that this needs some work but it does its job.

  2. #2
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Quote Originally Posted by mxtrix View Post
    Hey guys, I have just begun writing an updated air runecrafter and found that the getrunenergy function was non-existent (it has not yet been updated). I have created a make-do function which can be used to approximate it pretty accurately (within 5%). Here is the function if it would be of use to anyone:

    I understand that this needs some work but it does its job.
    Updated it in browser to srl 6 standards. Can you add it to lib/interfaces/minimap.simba and test it?

    If it works:


    Olly or another srl dev will review it, and probably add it. Mention me if you need help with that.

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

    .. code-block:: pascal

        function TRSMinimap.getRunEnergy(): Integer;

    Returns the percentage of run energy left.

    .. note::

        - by mxtrix
        - Last Updated: 19 April 2014 by mxtrix

    Example:

    .. code-block:: pascal

        if (minimap.GetRunEnergy() > 50) then
          minimap.toggleRun(True);
    *)

    function minimap.getRunEnergy(): Integer;
    const
      HEIGHTPERRATIO = 3.846;  //height of yellow run energy to percentage ratio
      ENERGYCOLOUR = 1126294;  //Yellow energy colour
      TOLERANCE = 30;          //Yellow energy colour tolerance
    var
      YellowPts: TPointArray;
      h, percApprox : integer;
      j : TBox;
    begin
      findColorsTolerance(YellowPts, ENERGYCOLOUR, self.button[MM_BUTTON_RUN].bounds, TOLERANCE ); // Creates a TPointArray of matching points in the run icon area
      j := GetTPABounds(YellowPts); // Convert the TPArray bounds to a TBox
      h := j.getHeight(); // Find the height of the TBox
      percApprox := Round(HEIGHTPERRATIO * h); // Thus, find the percentage- 100% was ~26
      Result := percApprox; // Make the result equal to the percentage
    end;
    Working on: Tithe Farmer

  3. #3
    Join Date
    Sep 2010
    Location
    Finland
    Posts
    298
    Mentioned
    8 Post(s)
    Quoted
    37 Post(s)

    Default

    I cleaned your code and removed the unnecessary variables. In lape you can chain type functions so it can make your code cleaner. Haven't tested if this works, but if it does then do what masterBB instructed you in his post.

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

    .. code-block:: pascal

        function TRSMinimap.getRunEnergy(): Integer;

    Returns the percentage of run energy left.

    .. note::

        - by mxtrix
        - Last Updated: 19 April 2014 by mxtrix

    Example:

    .. code-block:: pascal

        if (minimap.GetRunEnergy() > 50) then
          minimap.toggleRun(True);
    *)

    function TRSMinimap.getRunEnergy(): integer;
    const
      HEIGHTPERRATIO = 3.846;  //height of yellow run energy to percentage ratio
      ENERGYCOLOUR = 1126294;  //Yellow energy colour
      TOLERANCE = 30;          //Yellow energy colour tolerance
    var
      yellow : TPointArray; //I'm not entirely sure how SRL6 variable naming goes.
    begin
      findColorsTolerance(yellow, ENERGYCOLOUR, self.button[MM_BUTTON_RUN].bounds, TOLERANCE);

      result := (round(HEIGHTPERRATIO * (yellow.getBounds().getHeight())));
    end;
    Rusting away

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
  •