SRL Archive - Help and Support

Always monitor for colour


me_ntal

2010-11-26 06:22:24

Ok using a scar for custom purpose.

I always need to be able monitor for colour and if found interupt other procedures and run another.
Im aware of how to find a color, Just dont understand the procedure set up i should use

Been along time since ive done this.

Sir R. M8gic1an

2010-11-26 07:16:29


repeat
wait(50);
until(GetColor(x,y) = 000000)

AnotherProcedure();

or


repeat
wait(50);
if GetColor(x,y) = 000000 then
AnotherProcedure();
until(false)


~RM

me_ntal

2010-11-26 07:18:39

No that will mean, my procedures will have to wait to run or might miss it.

NCDS

2010-11-26 07:51:37

The 'Wait(50)' RM posted is simply to avoid lag.

Shuttleu

2010-11-26 08:19:54

you could use SetTimeout or a TTimer
if thats what you mean

~shut

Frement

2010-11-26 08:20:32

Heres some pseudo code (if you can call this that):
procedure TheProc;
while (not GetColor(x, y, color)) do begin
Myproc;
MyFunc(a, x, d);
end
//here proceed with the things you want to do when it gets the color
TheProc; //now return to _self_
end

EDIT: And heres some working code (tested it with MS Paint):
program new;

function ColorIs(Color: Integer): boolean;
begin
Result := False;
if (GetColor(100, 100) = Color) then begin
Result := True;
end;
end;

procedure WaitForC;
begin
while (not ColorIs(16777215)) do begin
ClearDebug;
Writeln('Waiting for the color...');
Sleep(10);
end;
ClearDebug;
Writeln('Color is there!');
Sleep(5000000);
WaitForC;
end;

begin
WaitForC;
end.

bbri06

2010-11-26 15:45:57

I wanted to do this a few months ago, but I think the only way I found to do it(if I remember correctly) was to write a plugin.

lordsaturn

2010-11-26 16:53:37

afaik multiple threads would be the simplest way to solve this problem.

me_ntal

2010-11-27 03:01:50

Your a genius lord.

Sir R. M8gic1an

2010-11-27 13:44:40

Considerin we don't have multiple threading….

SetTimeout has a reputation for failing

~RM

Tniffoc

2010-11-27 22:59:03

From: Sir R. Magician
Considerin we don't have multiple threading….

SetTimeout has a reputation for failing

~RM


Cough. Plugin. Cough.

BTW: First post in like a year.

lordsaturn

2010-11-27 23:49:33

Describe your situation mental? I might be able to help.

Welcome back tniffoc.