SRL Archive - First Scripts

Simple color finder, doesnt work


yahretzkee

2009-12-28 09:24:14

Hi everyone!

I've been a scripter about 2 years ago, made some nice scripts which were published and had a alot of downloads and active users.

Now, after 2 years I want to play around and see how do things look like now.

So here we are, I've made a really simple begginer's script, which should look for a color in the game area and automaticly click on it, when its found.
Then there is a simple command which informs us about that, and then the program waits for 5 seconds.

The problem is, nothing is happening. The script is running, it seems fine, but the mouse doesn't even move. Maybe i missed something, maybe after 2 years there are some new commands? I dont know. Anyway, I thought this forum is just for this - to help people, so here I am, waiting for help :)

Here's the code:


program Simple;

{.include SRL/SRL.scar}

var
x,y : Integer;

begin repeat
if FindColor(x,y,669001,1,1,600,600)=true then
begin
Mouse(x,y,1,1,true);
Wait(5000);
Writeln('Color Found!');
end;
until(false);
end.

Naum

2009-12-28 09:57:29

Hmm, instead of If blah = true then.. you can just do If Blah Then, I guess the latter looks much better :).

As for your problem, I would think it were a problem of co-ordinates (x1, y1, x2, y2) and/or the color you picked.

You might want to try picking it again, or using a completely different color :)

Sabzi

2009-12-28 10:04:12

Or the client-targeting mucked up as it happens nowadays quiet often.
You know the cross-hair, right?

Try picking the color again just to be sure and because Naum said that too :D, go to Client > Reset specified window and then target the client again with the cross-hair.

yahretzkee

2009-12-28 10:28:38

Ok, so here is how it looks like now:

program Simple;

{.include SRL/SRL.scar}

var
x,y : Integer;

begin repeat
if FindColor(x,y,1655606,1,1,600,600) then
begin
Mouse(x,y,1,1,true);
Wait(5000);
Writeln('Color Found!');
end;
until(false);
end.

I've changed the colour, I've changed the FindColor command (there is no "If Blah = true" anymore).

the mouse doesnt move anyway, the script doesnt even write the Writeln command.

Naum

2009-12-28 10:48:02

Show us what your trying to find?

yahretzkee

2009-12-28 12:53:18

Grass? Tree? Road? Anything.

Naum

2009-12-28 13:02:34

From: yahretzkee
Grass? Tree? Road? Anything.


Your problem could be with tolerance, try this puppy:

program New;
{.Include SRL/SRL.Scar}

Var
X, Y: Integer;
TB : TBox;

Begin
SetupSRL;
ActivateClient;
Wait(999);
GetClientDimensions(TB.x2, TB.y2);
If FindColorTolerance(x, y, 1655606, TB.x1, TB.y1, TB.x2, TB.y2, 15) Then
MMouse(X, Y, 0, 0);
End.

Be sure to activate your client, I just added some tolerance to the color. GetClientDimensions gets the width and height of the place you've specified, you may change that.

yahretzkee

2009-12-28 13:13:33

It doesn't work. Still.

yahretzkee

2009-12-28 13:32:02

Ok, I've made something like that:


program New;
{.Include SRL/SRL.Scar}

Var
x,y : Integer;

Begin
SetupSRL;
ClearDebug;
Repeat
If FindColor(x,y,1989453,7,8,500,300) then
begin
Writeln('The color was found!');
Mouse(x,y,1,1,true);
Wait(3000);
end else
Writeln('Color was not found');
Wait(3000);
until(false);
End.

If the color was found, it will let me know in the debug window.
If not, I will know that too.

So how does the debug window look like now?
"Color was not found" "Color was not found" "Color was not found"

So it seems that scar cant see colors on my computer?

Naum

2009-12-28 13:36:38

From: yahretzkee
Ok, I've made something like that:


program New;
{.Include SRL/SRL.Scar}

Var
x,y : Integer;

Begin
SetupSRL;
ClearDebug;
Repeat
If FindColor(x,y,1989453,7,8,500,300) then
begin
Writeln('The color was found!');
Mouse(x,y,1,1,true);
Wait(3000);
end else
Writeln('Color was not found');
Wait(3000);
until(false);
End.

If the color was found, it will let me know in the debug window.
If not, I will know that too.

So how does the debug window look like now?
"Color was not found" "Color was not found" "Color was not found"

So it seems that scar cant see colors on my computer?


No, I'm sure it can, again, i'll ask (sorry).

  • Try adding tolerance
  • Have you specified the client?
  • Try restarting SCAR
  • Are you using this on runescape?

yahretzkee

2009-12-28 13:50:01

I've added Tolerance. It doesn't work.
Yes I did. Im not stupid, and I'm not a beginner.
I've done it several times.
Yes I am.

yahretzkee

2009-12-28 22:21:39

Problem solved - my game was launched in HD mode.

But I've got another question - when I try to combine normal text and variables to show in the DebugWindow, an error appears. That's how does it look like:


[Error] (21120:52): Invalid number of parameters in script C:\Users\*****\Desktop\NameOfTheScript.scar

This is a piece of the script:


.....
Var
count : Integer;
.....
.....
.....
.....
Begin
count := count + 1;
Writeln('blahblahblah ',count,' blahblahblah');

Mr. Doctor

2009-12-28 22:25:37

Writeln('blahblahblah ' + IntToStr(Count) + ' blahblahblah');

IntToStr is a command to turn a integer to a string.

insanomano

2009-12-28 23:00:12

program FindColorClicker;
{.include SRL/SRL.scar}

Procedure FindColorAndClick;
var
x, y, i : Integer;

begin
i := i + 1; //YourColor //These are global coords for the mainscreen
if(not(FindColorTolerance(x, y, 534534535, MSX1, MSY1, MSX2, MSY2, 10))) then
begin
Writeln('Could not find color..');
end; //YourColor //These are global coords for the mainscreen
if (FindColorTolerance(x, y, 534534535, MSX1, MSY1, MSX2, MSY2, 10)) then
begin
Mouse(x,y,1,1,true);
Wait(5000);
Writeln('Color Found! and clicked');
writeln('Found and clicked color ' + IntToStr(i) + ' times.');
end;
end;

begin
FindColorAndClick;
end.

Nava2

2009-12-29 00:12:18

Is there an issue with the most recent post? Also please use SCAR tags or hilight tags.

yahretzkee

2009-12-29 08:49:08

From: Junkj
Writeln('blahblahblah ' + IntToStr(Count) + ' blahblahblah');

IntToStr is a command to turn a integer to a string.


Thanks, I forgot about that ;)

Topic can be closed now.