Results 1 to 16 of 16

Thread: Get Color works once

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Get Color works once

    so I have a function that checks for login:

    Simba Code:
    function FindObjectCTS(Color, w, h, tol, filter:Integer; hmod, smod:Extended):Boolean;
    var
      TPA:TPointArray;
      ATPA:T2DPointArray;
      CTS, X, Y, i:Integer;
    begin
      if (not ss_loggedin) then exit;
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(hmod, smod);
      if FindColorsSpiralTolerance(ss_MS.x, ss_MS.y, TPA, color, ss_MSX1, ss_MSY1, ss_MSX2, ss_MSY2, tol) then
      begin
        SetColorSpeed2Modifiers(0.02, 0.02);
        ColorToleranceSpeed(CTS);
        if (Length(TPA) < 1) then Exit;
        ATPA := TPAToATPAEx(TPA, w, h);
        filterTPAsBetween(ATPA, 1, filter);
        SortATPAFromFirstpoint(ATPA, Point(ss_MS.x, ss_MS.x));
        try
          MiddleTPAEx(ATPA[i], X, Y);
          mmouse(x, y, 0, 0)
          ClickMouse2(Mouse_left);
          Result := True;
        except
          Writeln('*****Out of range*****');
        end;
      end;
      SetColorSpeed2Modifiers(0.02, 0.02);
    end;

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

    Default

    Not sure if this is the problem but.. You seem to only restore CTS when you find the color.

    Code:
    function FindObjectCTS(Color, w, h, tol, filter:Integer; hmod, smod:Extended):Boolean;
    var
      TPA:TPointArray;
      ATPA:T2DPointArray;
      CTS, X, Y, i:Integer;
    begin
      if (not ss_loggedin) then exit;
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(hmod, smod);
      if FindColorsSpiralTolerance(ss_MS.x, ss_MS.y, TPA, color, ss_MSX1, ss_MSY1, ss_MSX2, ss_MSY2, tol) then
      begin
        SetColorSpeed2Modifiers(0.02, 0.02);
        ColorToleranceSpeed(CTS);
        if (Length(TPA) < 1) then Exit;
        ATPA := TPAToATPAEx(TPA, w, h);
        filterTPAsBetween(ATPA, 1, filter);
        SortATPAFromFirstpoint(ATPA, Point(ss_MS.x, ss_MS.x));
        try
          MiddleTPAEx(ATPA[i], X, Y);
          mmouse(x, y, 0, 0)
          ClickMouse2(Mouse_left);
          Result := True;
        except
          Writeln('*****Out of range*****');
        end;
      end;
      SetColorSpeed2Modifiers(0.02, 0.02);
      ColorToleranceSpeed(CTS); // Added this here.
    end;

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Janilabo View Post
    Not sure if this is the problem but.. You seem to only restore CTS when you find the color.

    Code:
    function FindObjectCTS(Color, w, h, tol, filter:Integer; hmod, smod:Extended):Boolean;
    var
      TPA:TPointArray;
      ATPA:T2DPointArray;
      CTS, X, Y, i:Integer;
    begin
      if (not ss_loggedin) then exit;
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(hmod, smod);
      if FindColorsSpiralTolerance(ss_MS.x, ss_MS.y, TPA, color, ss_MSX1, ss_MSY1, ss_MSX2, ss_MSY2, tol) then
      begin
        SetColorSpeed2Modifiers(0.02, 0.02);
        ColorToleranceSpeed(CTS);
        if (Length(TPA) < 1) then Exit;
        ATPA := TPAToATPAEx(TPA, w, h);
        filterTPAsBetween(ATPA, 1, filter);
        SortATPAFromFirstpoint(ATPA, Point(ss_MS.x, ss_MS.x));
        try
          MiddleTPAEx(ATPA[i], X, Y);
          mmouse(x, y, 0, 0)
          ClickMouse2(Mouse_left);
          Result := True;
        except
          Writeln('*****Out of range*****');
        end;
      end;
      SetColorSpeed2Modifiers(0.02, 0.02);
      ColorToleranceSpeed(CTS); // Added this here.
    end;
    I had that before, and I just retested it and it still didnt work

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

    Default

    Quote Originally Posted by Officer Barbrady View Post
    I had that before, and I just retested it and it still didnt work
    Yeah, like I said, I wasn't sure if that was the problem at all, I just noticed that you were missing it from your code.

    So, what exactly is the problem? You really should give some more information here...
    Like: Where does it stop working, at which part of the code?
    Also, have you been debugging it with WriteLn()'s etc..?

  5. #5
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Janilabo View Post
    Yeah, like I said, I wasn't sure if that was the problem at all, I just noticed that you were missing it from your code.

    So, what exactly is the problem? You really should give some more information here...
    Like: Where does it stop working, at which part of the code?
    Also, have you been debugging it with WriteLn()'s etc..?
    Ok, So before it cuts the tree, it has a login check and it returns true. After it clicks the tree and the tree is chopped down and it goes to find the next tree the login check returns false and therfor it tries to relog in

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

    Default

    Quote Originally Posted by Officer Barbrady View Post
    Ok, So before it cuts the tree, it has a login check and it returns true. After it clicks the tree and the tree is chopped down and it goes to find the next tree the login check returns false and therfor it tries to relog in
    Sounds like the problem is with ss_LoggedIn check then? ..or possibly somewhere even deeper.

    I recommend you add 1 more thing to this function, to prevent false-positives:

    Code:
    function FindObjectCTS(Color, w, h, tol, filter:Integer; hmod, smod:Extended):Boolean;
    var
      TPA:TPointArray;
      ATPA:T2DPointArray;
      CTS, X, Y, i:Integer;
    begin
      Result := False; // This here.
      if (not ss_loggedin) then exit;
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(hmod, smod);
      if FindColorsSpiralTolerance(ss_MS.x, ss_MS.y, TPA, color, ss_MSX1, ss_MSY1, ss_MSX2, ss_MSY2, tol) then
      begin
        SetColorSpeed2Modifiers(0.02, 0.02);
        ColorToleranceSpeed(CTS);
        if (Length(TPA) < 1) then Exit;
        ATPA := TPAToATPAEx(TPA, w, h);
        filterTPAsBetween(ATPA, 1, filter);
        SortATPAFromFirstpoint(ATPA, Point(ss_MS.x, ss_MS.x));
        try
          MiddleTPAEx(ATPA[i], X, Y);
          mmouse(x, y, 0, 0)
          ClickMouse2(Mouse_left);
          Result := True;
        except
          Writeln('*****Out of range*****');
        end;
      end;
      SetColorSpeed2Modifiers(0.02, 0.02);
      ColorToleranceSpeed(CTS); // Added this here.
    end;

  7. #7
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Janilabo View Post
    Sounds like the problem is with ss_LoggedIn check then? ..or possibly somewhere even deeper.

    I recommend you add 1 more thing to this function, to prevent false-positives:

    Code:
    function FindObjectCTS(Color, w, h, tol, filter:Integer; hmod, smod:Extended):Boolean;
    var
      TPA:TPointArray;
      ATPA:T2DPointArray;
      CTS, X, Y, i:Integer;
    begin
      Result := False; // This here.
      if (not ss_loggedin) then exit;
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(hmod, smod);
      if FindColorsSpiralTolerance(ss_MS.x, ss_MS.y, TPA, color, ss_MSX1, ss_MSY1, ss_MSX2, ss_MSY2, tol) then
      begin
        SetColorSpeed2Modifiers(0.02, 0.02);
        ColorToleranceSpeed(CTS);
        if (Length(TPA) < 1) then Exit;
        ATPA := TPAToATPAEx(TPA, w, h);
        filterTPAsBetween(ATPA, 1, filter);
        SortATPAFromFirstpoint(ATPA, Point(ss_MS.x, ss_MS.x));
        try
          MiddleTPAEx(ATPA[i], X, Y);
          mmouse(x, y, 0, 0)
          ClickMouse2(Mouse_left);
          Result := True;
        except
          Writeln('*****Out of range*****');
        end;
      end;
      SetColorSpeed2Modifiers(0.02, 0.02);
      ColorToleranceSpeed(CTS); // Added this here.
    end;
    Can't be a problem with that. Because I restart the script and it works

  8. #8
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Or better yet...

    Simba Code:
    function FindObjectCTS(Color, w, h, tol, filter:Integer; hmod, smod:Extended):Boolean;
    var
      TPA:TPointArray;
      ATPA:T2DPointArray;
      X, Y, i:Integer;
    begin
      if (not ss_loggedin) then exit;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(hmod, smod);
      FindColorsSpiralTolerance(ss_MS.x, ss_MS.y, TPA, color, ss_MSX1, ss_MSY1, ss_MSX2, ss_MSY2, tol);
      ColorToleranceSpeed(1);
      SetColorSpeed2Modifiers(0.02, 0.02);
      if (Length(TPA) > 0) then
      begin
        ATPA := TPAToATPAEx(TPA, w, h);
        filterTPAsBetween(ATPA, 1, filter);
        SortATPAFromFirstpoint(ATPA, Point(ss_MS.x, ss_MS.x));
        try
          MiddleTPAEx(ATPA[i], X, Y);
          mmouse(x, y, 0, 0)
          ClickMouse2(Mouse_left);
          Result := True;
        except
          Writeln('*****Out of range*****');
        end;
      end;
    end;

  9. #9
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Kasi View Post
    Or better yet...

    Simba Code:
    function FindObjectCTS(Color, w, h, tol, filter:Integer; hmod, smod:Extended):Boolean;
    var
      TPA:TPointArray;
      ATPA:T2DPointArray;
      X, Y, i:Integer;
    begin
      if (not ss_loggedin) then exit;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(hmod, smod);
      FindColorsSpiralTolerance(ss_MS.x, ss_MS.y, TPA, color, ss_MSX1, ss_MSY1, ss_MSX2, ss_MSY2, tol);
      ColorToleranceSpeed(1);
      SetColorSpeed2Modifiers(0.02, 0.02);
      if (Length(TPA) > 0) then
      begin
        ATPA := TPAToATPAEx(TPA, w, h);
        filterTPAsBetween(ATPA, 1, filter);
        SortATPAFromFirstpoint(ATPA, Point(ss_MS.x, ss_MS.x));
        try
          MiddleTPAEx(ATPA[i], X, Y);
          mmouse(x, y, 0, 0)
          ClickMouse2(Mouse_left);
          Result := True;
        except
          Writeln('*****Out of range*****');
        end;
      end;
    end;
    Ok, made them all like thatm still returns false after it clicks a tree

  10. #10
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Quote Originally Posted by Officer Barbrady View Post
    Ok, made them all like thatm still returns false after it clicks a tree
    Hint: never use try statements when debugging.

    Edit: whats i?
    Last edited by Kasi; 07-14-2013 at 11:45 PM.

  11. #11
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Kasi View Post
    Hint: never use try statements when debugging. i = ????
    Removed all the try's

    Still returns false

  12. #12
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Quote Originally Posted by Officer Barbrady View Post
    Removed all the try's

    Still returns false
    can't possibly return false, as again its procedural, if it clicks then it cant possibly fail on Result := true;
    try debugging by sticking a Writeln('Clicked'); under that Result := true;?

  13. #13
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Kasi View Post
    can't possibly return false, as again its procedural, if it clicks then it cant possibly fail on Result := true;
    try debugging by sticking a Writeln('Clicked'); under that Result := true;?
    No the login check is return false after the tree is clicked

  14. #14
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Quote Originally Posted by Officer Barbrady View Post
    No the login check is return false after the tree is clicked
    PM Teamviewer details again?

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

    Default

    How about this:

    Code:
    function FindObjectCTS(color, w, h, tol, filter: Integer; hmod, smod: Extended): Boolean;
    var
      TPA: TPointArray;
      ATPA: T2DPointArray;
      X, Y, CTS, hm, sm: Integer;
    begin
      Result := False;
      if not ss_LoggedIn then
        Exit;
      CTS := GetToleranceSpeed;
      GetToleranceSpeed2Modifiers(hm, sm);
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(hmod, smod);
      FindColorsSpiralTolerance(ss_MS.x, ss_MS.y, TPA, color, ss_MSX1, ss_MSY1, ss_MSX2, ss_MSY2, tol);
      ColorToleranceSpeed(CTS);
      SetColorSpeed2Modifiers(hm, sm);
      if (Length(TPA) > 0) then
      begin
        ATPA := TPAToATPAEx(TPA, w, h);
        FilterTPAsBetween(ATPA, 1, filter);
        if (Length(ATPA) > 0) then
        begin
          SortATPAFromFirstPoint(ATPA, Point(ss_MS.x, ss_MS.x));
          MiddleTPAEx(ATPA[0], X, Y);
          MMouse(X, Y, 0, 0);
          ClickMouse2(mouse_Left);
          Result := True;
        end;
      end;
    end;

  16. #16
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Fixed :P

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
  •