Results 1 to 11 of 11

Thread: 4 Additions to Color.scar

  1. #1
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default 4 Additions to Color.scar

    SCAR Code:
    {*******************************************************************************
    function WaitForColor(x, y, Color, TimeOut: Integer): Boolean;
    by: TRiLeZ
    Description: Waits for a color at a point with a timeout.
    *******************************************************************************}

    function WaitForColor(x, y, Color, TimeOut: Integer): Boolean;
    var
      Start: Integer;
    begin
      MarkTime(Start);
      repeat
      Wait(1);
      if (TimeFromMark(Start) >= TimeOut) then Exit;;
      until GetColor(x, y) = Color;
      if (TimeFromMark(Start) < Timeout) then Result:= True;
    end;
    SCAR Code:
    {*******************************************************************************
    function WaitForColorTol(x, y, Color, TimeOut, Tol: Integer): Boolean;
    by: TRiLeZ
    Description: Waits for a color at a point with a timeout and tolerance.
    *******************************************************************************}

    function WaitForColorTol(x, y, Color, TimeOut, Tol: Integer): Boolean;
    var
      Start, cx, cy: Integer;
    begin
      MarkTime(Start);
      repeat
      Wait(1);
      if (TimeFromMark(Start) >= TimeOut) then Exit;;
      until FindColorTolerance(cx, cy, Color, x, y, x, y, Tol);
      if (TimeFromMark(Start) < Timeout) then Result:= True;
    end;
    SCAR Code:
    {*******************************************************************************
    function WaitForColorIn(xs, ys, xe, ye, Color, TimeOut: Integer): Boolean;
    by: TRiLeZ
    Description: Waits for a color in a box with a timeout.
    *******************************************************************************}

    function WaitForColorIn(xs, ys, xe, ye, Color, TimeOut: Integer): Boolean;
    var
      Start, cx, cy: Integer;
    begin
      MarkTime(Start);
      repeat
      Wait(1);
      if (TimeFromMark(Start) >= TimeOut) then Exit;;
      until FindColor(cx, cy, Color, xs, ys, xe, ye);
      if (TimeFromMark(Start) < Timeout) then Result:= True;
    end;
    SCAR Code:
    {*******************************************************************************
    function WaitForColorTolIn(xs, ys, xe, ye, Color, TimeOut, Tol: Integer): Boolean;
    by: TRiLeZ
    Description: Waits for a color in a box with a timeout and tolerance.
    *******************************************************************************}

    function WaitForColorTolIn(xs, ys, xe, ye, Color, TimeOut, Tol: Integer): Boolean;
    var
      Start, cx, cy: Integer;
    begin
      MarkTime(Start);
      repeat
      Wait(1);
      if (TimeFromMark(Start) >= TimeOut) then Exit;;
      until FindColorTolerance(cx, cy, Color, xs, ys, xe, ye, Tol);
      if (TimeFromMark(Start) < Timeout) then Result:= True;
    end;

    Tell me if you like my functions and if they'll be added in SRL.

  2. #2
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Positive.
    ~Hermen

  3. #3
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by TRiLeZ View Post
    SCAR Code:
    {*******************************************************************************
    function WaitForColor(x, y, Color, TimeOut: Integer): Boolean;
    by: TRiLeZ
    Description: Waits for a color at a point with a timeout.
    *******************************************************************************}

    function WaitForColor(x, y, Color, TimeOut: Integer): Boolean;
    var
      Start: Integer;
    begin
      MarkTime(Start);
      repeat
      Wait(1);
      if (TimeFromMark(Start) >= TimeOut) then Exit;;
      until GetColor(x, y) = Color;
      if (TimeFromMark(Start) < Timeout) then Result:= True;
    end;
    SCAR Code:
    {*******************************************************************************
    function WaitForColorTol(x, y, Color, TimeOut, Tol: Integer): Boolean;
    by: TRiLeZ
    Description: Waits for a color at a point with a timeout and tolerance.
    *******************************************************************************}

    function WaitForColorTol(x, y, Color, TimeOut, Tol: Integer): Boolean;
    var
      Start, cx, cy: Integer;
    begin
      MarkTime(Start);
      repeat
      Wait(1);
      if (TimeFromMark(Start) >= TimeOut) then Exit;;
      until FindColorTolerance(cx, cy, Color, x, y, x, y, Tol);
      if (TimeFromMark(Start) < Timeout) then Result:= True;
    end;
    SCAR Code:
    {*******************************************************************************
    function WaitForColorIn(xs, ys, xe, ye, Color, TimeOut: Integer): Boolean;
    by: TRiLeZ
    Description: Waits for a color in a box with a timeout.
    *******************************************************************************}

    function WaitForColorIn(xs, ys, xe, ye, Color, TimeOut: Integer): Boolean;
    var
      Start, cx, cy: Integer;
    begin
      MarkTime(Start);
      repeat
      Wait(1);
      if (TimeFromMark(Start) >= TimeOut) then Exit;;
      until FindColor(cx, cy, Color, xs, ys, xe, ye);
      if (TimeFromMark(Start) < Timeout) then Result:= True;
    end;
    SCAR Code:
    {*******************************************************************************
    function WaitForColorTolIn(xs, ys, xe, ye, Color, TimeOut, Tol: Integer): Boolean;
    by: TRiLeZ
    Description: Waits for a color in a box with a timeout and tolerance.
    *******************************************************************************}

    function WaitForColorTolIn(xs, ys, xe, ye, Color, TimeOut, Tol: Integer): Boolean;
    var
      Start, cx, cy: Integer;
    begin
      MarkTime(Start);
      repeat
      Wait(1);
      if (TimeFromMark(Start) >= TimeOut) then Exit;;
      until FindColorTolerance(cx, cy, Color, xs, ys, xe, ye, Tol);
      if (TimeFromMark(Start) < Timeout) then Result:= True;
    end;

    Tell me if you like my functions and if they'll be added in SRL.

    Half of what you have made is a variant of the functions already made in SRL. Furthermore, would you mind telling me the usage of waiting to get one pixel of color? Wouldn't it be wiser to 'FindColTol' it?

  4. #4
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    For example the bank screen uses now text finding but what the heck, you can wait 1000 before a brownish pixels comes up and tada bankscreen detected .

    It is useful.
    ~Hermen

  5. #5
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Hermen View Post
    For example the bank screen uses now text finding but what the heck, you can wait 1000 before a brownish pixels comes up and tada bankscreen detected .

    It is useful.
    Couldn't you do WaitColor instead?
    WaitColor also has tolerance, and is already in SRL

  6. #6
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Half of what you have made is a variant of the functions already made in SRL. Furthermore, would you mind telling me the usage of waiting to get one pixel of color? Wouldn't it be wiser to 'FindColTol' it?
    If you click something and it takes a number of seconds for something to appear, the script would wait for until the color pops up onto the screen.

    For example, clicking on a Lecture takes 1.5 - 3 seconds to appear so it will wait for the interface to appear and is faster than using one constant wait time.

    Also, aren't the color finding function built into SCAR and not made by SRL?

  7. #7
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I thought he made new ones, NOEZ.
    ~Hermen

  8. #8
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by TRiLeZ View Post
    If you click something and it takes a number of seconds for something to appear, the script would wait for until the color pops up onto the screen.

    For example, clicking on a Lecture takes 1.5 - 3 seconds to appear so it will wait for the interface to appear and is faster than using one constant wait time.

    Also, aren't the color finding function built into SCAR and not made by SRL?
    SCAR Code:
    {*******************************************************************************
    Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
    By: Rasta Magician
    Description: Waits for a color at (x, y) with tolerance Tol, returns true if found
    *******************************************************************************}

    Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
    var
      Time: integer;
    begin
      Result := False;
      Time := GetSystemTime + MaxTime;
      while Time < GetSystemTime do
        if SimilarColors(GetColor(x, y), Color, Tol) then
        begin
          Result := true;
          exit;
        end;
    end;

    (h)

  9. #9
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    SCAR Code:
    {*******************************************************************************
    Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
    By: Rasta Magician
    Description: Waits for a color at (x, y) with tolerance Tol, returns true if found
    *******************************************************************************}

    Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
    var
      Time: integer;
    begin
      Result := False;
      Time := GetSystemTime + MaxTime;
      while Time < GetSystemTime do
        if SimilarColors(GetColor(x, y), Color, Tol) then
        begin
          Result := true;
          exit;
        end;
    end;

    (h)
    I never saw that function before...
    What about WaitForColorIn and WaitForColorTolIn?

  10. #10
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I was testing out WaitColor and it dosnt seem to work for me =/
    I tested with my function and it worked perfectly.

  11. #11
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    // * Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean; // By Marpis, N1ke! & Rasta Magician
    // * Function WaitOption(S: String; Time: Integer): Boolean; // By N1ke!
    // * Function WaitUptextMulti(S: TStringArray; Time: integer): Boolean; // By Marpis & N1ke!
    // * Function WaitUptext(S: String; Time: Integer): Boolean; // By N1ke!
    // * Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean; // By Rasta Magician
    // * Function WaitFindColor(var x, y: integer; x1, y1, x2, y2, Color, Tol, MaxTime: integer): boolean; // By Rasta Magician
    // * Function WaitFindColorSpiral(var x, y: integer; x1, y1, x2, y2, Color, Tol, MaxTime: integer): boolean; // By Rasta Magician
    // * Function WaitColorCount(x1, y1, x2, y2, Color, Tol, MinCount, MaxCount, MaxTime: integer):boolean; // By Rasta Magician
    // * Function WaitFunc(Func: Function: boolean; MaxTime: integer): boolean; // By Rasta Magician
    SCAR Code:
    {*******************************************************************************
    Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
    By: Rasta Magician
    Description: Waits for a color at (x, y) with tolerance Tol, returns true if found
    *******************************************************************************}

    Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
    var
      Time: integer;
    begin
      Result := False;
      Time := GetSystemTime + MaxTime;
      while Time < GetSystemTime do
        if SimilarColors(GetColor(x, y), Color, Tol) then
        begin
          Result := true;
          exit;
        end;
    end;

    {*******************************************************************************
    Function WaitFindColor(var x, y: integer; Color, Tol, x1, y1, x2, y2, MaxTime: integer): Boolean;
    By: Rasta Magician
    Description: Waits for a color at (x1, y1, x2, y2) with tolerance Tol, returns true if found, coords returned to (x, y)
    *******************************************************************************}

    Function WaitFindColor(var x, y: integer; Color, x1, y1, x2, y2, Tol, MaxTime: integer): Boolean;
    var
      Time: integer;
    begin
      Result := False;
      Time := GetSystemTime + MaxTime;
      While GetSystemTime < Time do
        if FindColorTolerance(x, y, Color, x1, y1, x2, y2, Tol) then
        begin
          Result := true;
          exit;
        end;
    end;

    Therefore no, they won't be added to SRL as they already exist in SRL and are more efficient.

    Also, you might want to know that if you are looking for a color in just one place it is faster to do GetColor than findColor(x1, y1, x1, y1) as you did.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

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
  •