Results 1 to 3 of 3

Thread: tpa.getRandomPoint(), mouseTPA()

  1. #1
    Join Date
    Jul 2014
    Location
    My computer
    Posts
    78
    Mentioned
    8 Post(s)
    Quoted
    21 Post(s)

    Default tpa.getRandomPoint(), mouseTPA(), tba.sortFromPoint()

    Here are a few more functions I've made and found useful when scripting. Hope someone else can get some use out of them.

    Simba Code:
    //gets random point in a tpa.
    //by HKbotz
    function TPointArray.getRandomPoint(): TPoint;
    begin
      if (length(self) < 1) then
        result := point(-1, -1)
      else
        result := self[random(length(self))];
    end;


    //mouses a random point in a tpa
    //by HKbotz
    procedure mouseTPA(tpa: TPointArray; button: integer = MOUSE_MOVE; mmType: integer = MOUSE_HUMAN);
    begin
      mouse(tpa.getRandomPoint(), button, mmType);
    end;


    //sorts TBoxArray from point p
    //by HKbotz
    procedure TBoxArray.sortFromPoint(const p: TPoint);
    var
      tpa: TPointArray;
      tmpBoxArr: TBoxArray;
      i, j: integer;
    begin
      if (length(self) < 1) then
        exit();

      setLength(tpa, length(self));
      setLength(tmpBoxArr, length(self));
      for (i := 0) to (high(self)) do
        tpa[i] := self[i].getMiddle();

      tpa.sortFromPoint(p);
      j := 0;
      for (i := 0) to (high(tpa)) do
        for (j := 0) to (high(self)) do
        begin
          if (tpa[i].equals(self[j].getMiddle())) then
          begin
            tmpBoxArr[i] := self[j];
            break;
          end;
        end;
      self := tmpBoxArr;
    end;

    examples:
    Simba Code:
    var
      TPA: TPointArray;
      p: TPoint;
    begin
     //get the tpa using findColorsTolerance or something like that
      p := TPA.getRandomPoint();
    end.
    Simba Code:
    var
      TPA: TPointArray;
    begin
      //get the tpa using findColorsTolerance or something like that
      mouseTPA(TPA, MOUSE_LEFT);
    end.
    Simba Code:
    var
      tba: TBoxArray;
    begin
      //get the tba somehow
      tba.sortFromPoint(mainscreen.playerPoint);
    end.
    Last edited by HKbotz; 01-31-2015 at 05:34 AM. Reason: added tba.sortFromPoint()
    We must stop constantly fighting for human rights and equal justice in an unjust system, and start building a society where equal rights are an integral part of the design. --Jacque Fresco

  2. #2
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

  3. #3
    Join Date
    Feb 2015
    Posts
    9
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    mmm cant wait

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
  •