SRL Archive - Outdated Tutorials

Here you will learn to use my function DirectionScanner.


n3ss3s

2007-05-19 11:49:45

I put this to beginner tuts because I dont think the usage is very hard.
I hope its even worth a TUT lol :D

Lets begin of that what is its meaning to do.


It is made for color searching for constantly enlarging area. I hope enlarging is the right word for getting bigger.
You will make 2 points (lx,ly,lx2,ly2) which for scanning to north or south have to be on same vertical coords, and for west and east, same horizontal coords.then the function scans every pixel between lx,ly and lx2,ly2. If it doesnt find the color it moves the 2 points(the line) 1 pixel forward and continues until it has found the color or reaches MaxDistance given by the user. And now I realized that posting the function may be helpful lol.

function ColorOnLine(var ox, oy: integer; Dir: string; Color, Lx, Ly,
Lx2, Ly2: integer): boolean;
{ A support function for DirectionScanner.}
var A: integer;
begin
case Dir of
'n': begin
for A := Lx to Lx2 do
begin
if (GetColor(A, Ly) = Color) then
begin
MMouse(x, y, 0, 0);
GetMousePos(ox, oy);
result := true;
Break;
end;
end;
end;
'e': begin
for A := Ly to Ly2 do
begin
if (GetColor(A, Lx) = Color) then
begin
MMouse(x, y, 0, 0);
GetMousePos(ox, oy);
result := true;
Break;
end;
end;
end;
's': begin
for A := Lx to Lx2 do
begin
if (GetColor(A, Ly) = Color) then
begin
MMouse(x, y, 0, 0);
GetMousePos(ox, oy);
result := true;
Break;
end;
end;
end;
'w': begin
for A := Ly to Ly2 do
begin
if (GetColor(A, Lx) = Color) then
begin
MMouse(x, y, 0, 0);
GetMousePos(ox, oy);
result := true;
Break;
end;
end;
end;
end;
end;

function DirectionScanner(var cx, cy: integer; Direction: string;
MaxDistance, Lx, Ly, Lx2, Ly2, Color: integer): boolean;
{ DirectionScanner brought you by: n3ss3s}
{ All info about the function : www.srl-forums.com}
var A: integer;
begin
case Direction of
'n': begin
for A := 1 to MaxDistance do
begin
if (ColorOnLine(x, y, 'n', Color, Lx, Ly, Lx2, Ly2)) then
begin
result := true;
MMouse(x, y, 0, 0);
GetMousePos(Cx, Cy);
Break;
end;
Ly := Ly - 1;
Ly2 := Ly2 - 1;
end;
end;
'e': begin
for A := 1 to MaxDistance do
begin
if (ColorOnLine(x, y, 'e', Color, Lx, Ly, Lx2, Ly2)) then
begin
result := true;
MMouse(x, y, 0, 0);
GetMousePos(Cx, Cy);
Break;
end;
Lx := Lx + 1;
Lx2 := Lx2 + 1;
end;
end;
's': begin
for A := 1 to MaxDistance do
begin
if (ColorOnLine(x, y, 's', Color, Lx, Ly, Lx2, Ly2)) then
begin
result := true;
MMouse(x, y, 0, 0);
GetMousePos(Cx, Cy);
Break;
end;
Ly := Ly + 1;
Ly2 := Ly2 + 1;
end;
end;
'w': begin
for A := 1 to MaxDistance do
begin
if (ColorOnLine(x, y, 'w', Color, Lx, Ly, Lx2, Ly2)) then
begin
result := true;
MMouse(x, y, 0, 0);
GetMousePos(Cx, Cy);
Break;
end;
Lx := Ly - 1;
Lx2 := Ly2 - 1;
end;
end;
end;
end;
I posted the support function there too if someone wants to study.

WhoCares357

2007-05-19 18:40:29

You confused me very much.

~alex~

2007-05-19 20:17:56

From: WhoCares357
You confused me very much.


Same..

PwNZoRNooB

2007-05-20 02:24:15

Short and confusing :confused: :/

Hugolord

2007-05-20 03:52:42

i don't get it what can it be used for?

n3ss3s

2007-05-20 04:54:32

as I said my teaching skills are very bad.

It is made for color searching for constantly enlarging area. I hope enlarging is the right word for getting bigger.
You will make 2 points (lx,ly,lx2,ly2) which for scanning to north or south have to be on same vertical coords, and for west and east, same horizontal coords.then the function scans every pixel between lx,ly and lx2,ly2. If it doesnt find the color it moves the 2 points(the line) 1 pixel forward and continues until it has found the color or reaches MaxDistance given by the user. And now I realized that posting the function may be helpful lol.

function ColorOnLine(var ox, oy: integer; Dir: string; Color, Lx, Ly,
Lx2, Ly2: integer): boolean;
{ A support function for DirectionScanner.}
var A: integer;
begin
case Dir of
'n': begin
for A := Lx to Lx2 do
begin
if (GetColor(A, Ly) = Color) then
begin
MMouse(x, y, 0, 0);
GetMousePos(ox, oy);
result := true;
Break;
end;
end;
end;
'e': begin
for A := Ly to Ly2 do
begin
if (GetColor(A, Lx) = Color) then
begin
MMouse(x, y, 0, 0);
GetMousePos(ox, oy);
result := true;
Break;
end;
end;
end;
's': begin
for A := Lx to Lx2 do
begin
if (GetColor(A, Ly) = Color) then
begin
MMouse(x, y, 0, 0);
GetMousePos(ox, oy);
result := true;
Break;
end;
end;
end;
'w': begin
for A := Ly to Ly2 do
begin
if (GetColor(A, Lx) = Color) then
begin
MMouse(x, y, 0, 0);
GetMousePos(ox, oy);
result := true;
Break;
end;
end;
end;
end;
end;

function DirectionScanner(var cx, cy: integer; Direction: string;
MaxDistance, Lx, Ly, Lx2, Ly2, Color: integer): boolean;
{ DirectionScanner brought you by: n3ss3s}
{ All info about the function : www.srl-forums.com}
var A: integer;
begin
case Direction of
'n': begin
for A := 1 to MaxDistance do
begin
if (ColorOnLine(x, y, 'n', Color, Lx, Ly, Lx2, Ly2)) then
begin
result := true;
MMouse(x, y, 0, 0);
GetMousePos(Cx, Cy);
Break;
end;
Ly := Ly - 1;
Ly2 := Ly2 - 1;
end;
end;
'e': begin
for A := 1 to MaxDistance do
begin
if (ColorOnLine(x, y, 'e', Color, Lx, Ly, Lx2, Ly2)) then
begin
result := true;
MMouse(x, y, 0, 0);
GetMousePos(Cx, Cy);
Break;
end;
Lx := Lx + 1;
Lx2 := Lx2 + 1;
end;
end;
's': begin
for A := 1 to MaxDistance do
begin
if (ColorOnLine(x, y, 's', Color, Lx, Ly, Lx2, Ly2)) then
begin
result := true;
MMouse(x, y, 0, 0);
GetMousePos(Cx, Cy);
Break;
end;
Ly := Ly + 1;
Ly2 := Ly2 + 1;
end;
end;
'w': begin
for A := 1 to MaxDistance do
begin
if (ColorOnLine(x, y, 'w', Color, Lx, Ly, Lx2, Ly2)) then
begin
result := true;
MMouse(x, y, 0, 0);
GetMousePos(Cx, Cy);
Break;
end;
Lx := Ly - 1;
Lx2 := Ly2 - 1;
end;
end;
end;
end;
I posted the support function there too if someone wants to study.