n3ss3s
05-19-2007, 03:49 PM
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.
http://img120.imageshack.us/img120/503/82482526mn9.png
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.
I hope its even worth a TUT lol :D
Lets begin of that what is its meaning to do.
http://img120.imageshack.us/img120/503/82482526mn9.png
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.