SRL Archive - SRL Archives

2 New Functions - Timing.scar


TRiLeZ

2009-09-10 08:47:22

RM suggested for me to make a function to wait until a colour is gone so I made 2.
WaitColorGone and WaitColorGoneIn.


{*******************************************************************************
function WaitColorGone(Color, x, y, Tol, MaxTime: integer): Boolean;
By: TRiLeZ
Description: Waits until a colour is gone at (x, y) with tolerance and a timeout.
Results true if the colour disappeared at (x, y) within the time cap.
*******************************************************************************}
function WaitColorGone(Color, x, y, Tol, MaxTime: integer): Boolean;
var
Time: Integer;
begin
Result := False;
if Tol = 0 then Tol := 1;
Time := GetSystemTime + MaxTime;
while (Time > GetSystemTime) do
begin
if (not SimilarColors(GetColor(X, Y), Color, Tol)) then
begin
Result := True;
Exit;
end;
Wait(5 + Random(6));
end;
end;

{*******************************************************************************
function WaitColorGoneIn(Colour, x1, y1, x2, y2, Tol, MaxTime: integer): Boolean;
By: TRiLeZ
Description: Waits until a colour is gone in an area with tolerance and a timeout.
Results true if the colour disappeared in the area within the time cap.
*******************************************************************************}
function WaitColorGoneIn(Colour, x1, y1, x2, y2, Tol, MaxTime: integer): Boolean;
var
Time, CX, CY: Integer;
begin
Result := False;
if Tol = 0 then Tol := 1;
Time := GetSystemTime + MaxTime;
while (Time > GetSystemTime) do
begin
if (not FindColorTolerance(cx, cy, Colour, x1, y1, x2, y2, Tol)) then
begin
Result := True;
Exit;
end;
Wait(5 + Random(6));
end;
end;

Read their descriptions.

TRiLeZ

2009-09-16 02:12:16

Anything happening with these functions?

YoHoJo

2009-09-16 02:27:31

No bumps! :D
They are neat but i dont know any major uses for them, thers other ways to do what your trying to do except looking for color. But good job experimenting, thinking, and making new stuff, im sure people will find them helpful and implement them into their scripts!

Main

2009-09-16 03:14:10

Maybe we could use this to detect if tree is gone? ^^?

noidea

2009-09-16 03:58:00

From: Main_Ftw
Maybe we could use this to detect if tree is gone? ^^?

No since the Camera slowly moves.

Well you could do like

TPA := [Point(), Point(), Point(), Point(), Point()];
for i := 0 to high(TPA) do
if WaitCol() then
idk..

marpis

2009-09-16 08:23:47

why is there
if Tol = 0 then Tol := 1?
You can't search for exact color

TRiLeZ

2009-09-16 09:12:10

tol 0 dosnt work…

Gu3st...

2009-09-16 13:29:48

begin
WriteLn(BoolToStr(SimilarColors(0, 1, 0)));
end.

Successfully compiled (28 ms)
False
Successfully executed


Works for me

Sir R. M8gic1an

2009-09-16 17:03:48

From: Zyt3x
begin
WriteLn(BoolToStr(SimilarColors(0, 1, 0)));
end.



Works for me




if SimilarColors(0, 0, 0) then
writeln('epic')
else
writeln('fail');

It'll fail unless you are using scar 3.22+

I like these funcs.

~RM

Sir R. M8gic1an

2009-09-16 18:13:06

Committed :)

~RM