Results 1 to 12 of 12

Thread: Help With if FindColorSpiralTolerance

  1. #1
    Join Date
    Dec 2011
    Posts
    209
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default Help With if FindColorSpiralTolerance

    I want it to find a certain color between a certain space, when I run:
    if FindColorSpiralTolerance(x, y, 15641600, 16, 25, 264, 228, 20) then
    It finds it at the top left of the screen but I want it to search down by the right middle any idea's on how to make it search there and only there!

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    16, 25, 264, 228 is the search radius u defined.
    If u want to search bigger area just adjust the parameter?

    Spiral functions will search from the centre of the defined area so just use FindColorTolerance if u want it to search top left to btm down of ur defined search area.

  3. #3
    Join Date
    Dec 2011
    Posts
    209
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    16, 25, 264, 228 is the search radius u defined.
    If u want to search bigger area just adjust the parameter?

    Spiral functions will search from the centre of the defined area so just use FindColorTolerance if u want it to search top left to btm down of ur defined search area.
    So what is "16, 25, 264, 288" which number is the x and y coords?

  4. #4
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Hmm u have no idea what u defined? Or are u editing someone else's script?
    (16,25) is the start coordinate, (top left coordinate of the rectangle), and (264,288) is the end coordinate (btm right of the rect). You can know the coordinate by dragging ur crosshair to RS client and coordinates of ur current mouse position will be shown on the btm left of simba client.

  5. #5
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    FindColorSpiralTolerance doesn't necessarily search from the centre of the box you defined, it will search in a spiral formation from the x and y co-ordinates you defined at the beginning, so if you leave them as x and y it will most probably search in a spiral and select the colour closest to your mouse's current position.

    Keeping in mind that it will only search within the rectangle you define in the other co-ords (16,25,264,288).

  6. #6
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by p1ng View Post
    FindColorSpiralTolerance doesn't necessarily search from the centre of the box you defined, it will search in a spiral formation from the x and y co-ordinates you defined at the beginning, so if you leave them as x and y it will most probably search in a spiral and select the colour closest to your mouse's current position.

    Keeping in mind that it will only search within the rectangle you define in the other co-ords (16,25,264,288).
    I've seen some ppl saying this lately but i still dont understand how u declare the variable parameter as constants?
    i.e. FindColorSpiralTolerance(50,50,123456,1,1,1,1,15); will return a compiling error.
    Or u actually have to assign the variables x,y before u call the function?

    EDIT: guess i understand it now. If u did not assign the x,y it should be the default (0,0), in which if it isn't in ur search radius it will then automatically start from the center. (i.e. there is no need to assign them if (0,0) is not within ur search radius)

    EDIT2: Read the delphi code the function doesn't even make use of the (x,y) u originally assigned? Can anyone explain how it works?
    function FindColorSpiralTolerance(var x,y: Integer; color, xs, ys, xe, ye,
    tolerance: Integer; window: HWND): Boolean;
    var
    xx, yy, i, direction, length: Integer;
    TestDC: HDC;
    WndRECT: TRect;
    label
    Done;
    begin
    GetWindowRect(window, WndRECT);
    xx := round((WndRECT.Right - WndRECT.Left) / 2);
    yy := round((WndRECT.Bottom - WndRECT.Top) / 2);
    TestDC := GetWindowDC(Window);
    direction := 0;
    length := 1;
    if SimilarColors(color, GetPixel(TestDC, xx, yy), tolerance) then goto Done;
    while not ((xx < xs) or (yy < ys) or (xx > xe) or (yy > ye)) do
    begin
    for i := 1 to length do
    begin
    case direction of
    0: yy := yy - 1;
    1: xx := xx + 1;
    2: yy := yy + 1;
    3: xx := xx - 1;
    end;
    if SimilarColors(color, GetPixel(TestDC, xx, yy), tolerance) then goto Done;
    end;
    direction := (direction + 1) mod 4;
    if (direction mod 2) = 0 then length := length + 1;
    end;
    if SimilarColors(color, GetPixel(TestDC, xx, yy), tolerance) = False then
    begin;
    x := -1;
    y := -1;
    Result := False;
    Exit
    end;
    Done:
    x := xx;
    y := yy;
    Result := True;
    end;

  7. #7
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ahh, findcolorspiraltolerance, my favorite!
    So, To start off with, findcolorspiraltolerance will find a color that you name, and assign its co-ordinates to X and Y. For example, you can use
    Simba Code:
    begin
     if findcolorspiraltolerance(x, y, color, MSX1, MSY1, MSX2, MSY2, 5) then
          Mouse(x, y, 5, 5, 1)
    end;
    This would find the color of your choice anywhere on the main screen, with a color tolerance of 5 (always set a bit of tolerance, jagex changes colors alot), then assign the point where it found the color to x, y.
    Next, it would Move the mouse to x, y, which we have just assigned to the point where we found our color, randomness of 5 (the mouse will move within 5 pixels of x, y) then click on it.
    One last thing though, before you ever use variables, such as x, y, you must assign them as global or local variables. If you are going to use x, y as your color throughout the script, assign it as a global variable. To do This, Simply write this in under Program (programname) at the top.
    Simba Code:
    Program (programname);
    var
      x, y:integer;  // these variables are global, they can be used at any point in your script
    begin
    blah blah blah
    end.
    What this tells us is x and y are integers, and now we can assign x and y to any integers at any point in the script. However, If you want x and y to only be used in one procedure, you can list it as a local variable. To name a local variable, you write
    var
    x, y:integer;
    But you write this under your procedure name, as follows.
    Simba Code:
    Procedure (Procedure name);
    var
      x, y:integer //These variables are local, they will only be used in this one procedure
    begin
    end;
    Hope I've cleared any confusion with findcolorspiraltolerance, if not, let me know!

    E: Reading over your question again, I dont think I've answered it, lol
    If your looking for a color, and you know exactly where its going to be (anything static) then you can narrow down your area to search for the color. Above I used
    Simba Code:
    findcolorspiraltolerance(x, y, color, MSX1, MSY1, MSX2, MSY2, 5)
    This searches anywhere on the main screen, however lets say you know it will be in the bottom left quadrant of your screen. You can then drag the crosshair to your runescape screen, and pick the top left point of your search area, then the bottom right point of your search area. Now at the botom of your simba, in the debug box, you will have something like this
    Picked color 723722 at (333, 222
    Picked color 777777 at (111, 5)
    Now enter these co-ordinates into the findcolorspiraltolerance function, and it will only search in that area. For the points I Picked, I would enter
    Simba Code:
    findcolorspiraltolerance(x, y, mycolor, 333, 222, 111, 5, 5)
    Any more questions?
    Last edited by Footy; 07-03-2012 at 02:39 PM.
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  8. #8
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Im afraid not, all u explained is applicable to FindColortolerance too. U did not point out the main difference between spiral and non-spiral. (and how the code i posted utilize the assigned x,y values)

    EDIT: footy we are talking about the way spiral functions search from center...All that u said so far makes no distinction between spiral and nonspiral.

    Seems like Main is going to enlighten me

  9. #9
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The difference between the two is that spiral will search from the middle of your search area that you have assigned, and search outward. findcolortolerance will search from the top left to the bottom right. Lets say you want to find your HP bar, but you dont want to get some noobs HP bar instead. (There are easier ways then this) You would use findcolorspiraltolerance then it would search from the middle outward, thus finding your HP bar before anyone elses.

    E: You dont really need to know what the Delphi code means, I dont, and I still know how to use it fine. The only useful part for me in that are the parameters, which tell you what you enter in the () after findcolorspiraltolerance
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  10. #10
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    I've been having trouble with FindColorSpiralTolerance lately as well, with it selecting colours found in the outer regions of it's search area when there are closer ones with a matching colour. So if someone could clear up where it does actually start its spiral from that would be greatly appreciated.

    PS- sorry for the semi-thread hijack

  11. #11
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well, I've been taught that it starts its spiral in the middle of your "box" you've made, but I dont see why it would be finding stuff outside the area. If it gets too complicated, ACA is always a possibility!
    E: sorry riwu, didnt understand ur question, lol.
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  12. #12
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    No it isn't finding anything outside my defined search area, it's just skipping past colours that are appropriate and selecting others which are closer to the edge of the box..

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
  •