n3ss3s
2007-05-15 14:27:19
DirectionScanner
Usage
- Scans to the given direction for given color, until distance from start has reached "MaxDistance".
- Uses "ColorOnLine" function I made.
How To Use
In this function, you will create a line from 2 points.
(Lx,Ly,Lx2,Ly2)
The points must be on the same
- for North and South, Same horizontal coordinates
- for East and West, Same vertical coordinates.
The function got Scanner to its name because the scanning movement is same as using a scanner :D Groovy
It is not complete yet, It has some kind of problem with finding the color but Its possible I just cant use my function. Released because couldnt wait any longer lol.
When this function is complete, I think its totally worth
Usage
- Scans to the given direction for given color, until distance from start has reached "MaxDistance".
- Uses "ColorOnLine" function I made.
How To Use
In this function, you will create a line from 2 points.
(Lx,Ly,Lx2,Ly2)
The points must be on the same
- for North and South, Same horizontal coordinates
- for East and West, Same vertical coordinates.
The function got Scanner to its name because the scanning movement is same as using a scanner :D Groovy
It is not complete yet, It has some kind of problem with finding the color but Its possible I just cant use my function. Released because couldnt wait any longer 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 : http://www.villavu.com/forum/showthread.php?t=10160?p=112637#post112637}
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;
Please post questions here and if someone has idea, about the problem or for improving, plz post.When this function is complete, I think its totally worth
SRL New Functions Post here anything worth implementing into SRL…