Results 1 to 10 of 10

Thread: findColorsSpiralTolerance - Multiple colors?

  1. #1
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default findColorsSpiralTolerance - Multiple colors?

    Hey,

    I'm trying to use the following code to find multiple colors at the same time
    Simba Code:
    findColorsSpiralTolerance(x, y, TPA, 8087871, mainScreen.getBounds(), 3, colorSetting(2, 0.25, 0.84));

    I tried the following, but I kept getting an error.
    Simba Code:
    findColorsSpiralTolerance(x, y, TPA, [8087871, 12427872], mainScreen.getBounds(), 3, colorSetting(2, 0.25, 0.84));


    How can I get this function to work and to find multiple colors without having to do the following?
    Simba Code:
    findColorsSpiralTolerance(x, y, TPA, 8087871, mainScreen.getBounds(), 3, colorSetting(2, 0.25, 0.84));
          if (Length(TPA) < 1) then
            findColorsSpiralTolerance(x, y, TPA, 12427872, mainScreen.getBounds(), 3, colorSetting(2, 0.25, 0.84));

  2. #2
    Join Date
    Jun 2014
    Location
    Oklahoma
    Posts
    336
    Mentioned
    22 Post(s)
    Quoted
    231 Post(s)

    Default

    You would have to do 2 searches.

    You could just do this.

    Simba Code:
    findColorsSpiralTolerance(x, y, TPA, 8087871, mainScreen.getBounds(), 3, colorSetting(2, 0.25, 0.84));
    findColorsSpiralTolerance(x, y, TPA2, 12427872, mainScreen.getBounds(), 3, colorSetting(2, 0.25, 0.84));
    TPA := combineTPA(TPA,TPA2);

  3. #3
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by Camel View Post
    You would have to do 2 searches.

    You could just do this.

    Simba Code:
    findColorsSpiralTolerance(x, y, TPA, 8087871, mainScreen.getBounds(), 3, colorSetting(2, 0.25, 0.84));
    findColorsSpiralTolerance(x, y, TPA2, 12427872, mainScreen.getBounds(), 3, colorSetting(2, 0.25, 0.84));
    TPA := combineTPA(TPA,TPA2);

    It's just the problem is I don't have to find two colors, I have probably 15.
    So to repeat that 15 times.. :S

    Is there any other better piece of code to find about 15 colors (In an array?) instead of having 15 lines, one for each color?

    Thanks.

  4. #4
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by TomTop View Post
    It's just the problem is I don't have to find two colors, I have probably 15.
    So to repeat that 15 times.. :S

    Is there any other better piece of code to find about 15 colors (In an array?) instead of having 15 lines, one for each color?

    Thanks.
    Simba Code:
    var
       i: integer;
       oneColor, allColors: TPointArray;
       colors: TIntegerArray

       colors := [66815,329215,263679,132351,1445887,198143,197887,
          1642751,394751,1577215,460543,1643007,1117439];
       
       for i := 0 to high(colors) do
          if (findcolors(oneColor, colors[i], mainscreen.getBounds())) then
             allColors.combine(oneColor);

  5. #5
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by bonsai View Post
    Simba Code:
    var
       i: integer;
       oneColor, allColors: TPointArray;
       colors: TIntegerArray

       colors := [66815,329215,263679,132351,1445887,198143,197887,
          1642751,394751,1577215,460543,1643007,1117439];
       
       for i := 0 to high(colors) do
          if (findcolors(oneColor, colors[i], mainscreen.getBounds())) then
             allColors.combine(oneColor);
    How would I go about implementing that?
    By that I mean to get it to, for example, right click on each color found?

    Thanks.

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

    Default

    Simba Code:
    function FindColorsTolEx(var TPA:TPointArray; colors:TIntegerArray; bounds:TBox; tol:Int32): Boolean;
    var
      i:Int32;
      tmp:TPointArray;
    begin
      for i:=0 to High(colors) do
      begin
        FindColorsTolerance(tmp, colors[i], bounds, tol);
        TPA := CombineTPA(TPA,tmp);
      end;
      Result := Length(TPA) <> 0;
    end;
    !No priv. messages please

  7. #7
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    Simba Code:
    function FindColorsTolEx(var TPA:TPointArray; colors:TIntegerArray; bounds:TBox; tol:Int32): Boolean;
    var
      i:Int32;
      tmp:TPointArray;
    begin
      for i:=0 to High(colors) do
      begin
        FindColorsTolerance(tmp, colors[i], bounds, tol);
        TPA := CombineTPA(TPA,tmp);
      end;
      Result := Length(TPA) <> 0;
    end;
    How would I get that to right click on each color? And then if it findes an Option in the Choose option, to get it to exit the function?

    My current script does that, it's just the color finding is very messed up, I think I understand how to implement bonsais code.. I think.

  8. #8
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by TomTop View Post
    How would I get that to right click on each color? And then if it findes an Option in the Choose option, to get it to exit the function?

    My current script does that, it's just the color finding is very messed up, I think I understand how to implement bonsais code.. I think.
    Your example used the variable TPA. In my code, I gathered the color data into allColors. So whatever you did with TPA you could do with allColors.

    My post was more of a hint to show you the idea of how to have the array, loop through it, and combine results into a single tpa. Your need is a little more complicated with tolerance/cts2 settings.

  9. #9
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by bonsai View Post
    Your example used the variable TPA. In my code, I gathered the color data into allColors. So whatever you did with TPA you could do with allColors.

    My post was more of a hint to show you the idea of how to have the array, loop through it, and combine results into a single tpa. Your need is a little more complicated with tolerance/cts2 settings.

    There is a problem with your code, or atleast, how can I move the mouse the where the color is?

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

    Default

    Quote Originally Posted by TomTop View Post
    There is a problem with your code, or atleast, how can I move the mouse the where the color is?
    bonsai already told you, you need to loop through the TPA which contains the found TPoint's (pixels).

    Just a basic example:

    Simba Code:
    function FindColorsTolEx(var TPA: TPointArray; colors: TIntegerArray; bounds: TBox; tol: Int32): Boolean;
    var
      i: Int32;
      tmp: TPointArray;
    begin
      SetLength(TPA, 0);
      for i := 0 to High(colors) do
        if FindColorsTolerance(tmp, colors[i], bounds.X1, bounds.Y1, bounds.X2, bounds.Y2, tol) then
          TPA := CombineTPA(TPA, tmp);
      Result := (Length(TPA) > 0);
    end;

    var
      found: TPointArray;
      w, h, i: Integer;

    begin
      GetClientDimensions(w, h);
      if FindColorsTolEx(found, [0, 255], IntToBox(0, 0, (w - 1), (h - 1)), 0) then
      for i := 0 to High(found) do
        MoveMouse(found[i].X, found[i].Y); // NOTE: Don't use MoveMouse in RuneScape!
    end.

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
  •