当我尝试编译脚本时,我得到“类型不匹配”而且我不知道如何解决这个问题。
此行给出了类型不匹配:
If length(TPA) <500 then begin
这是我想要运行的功能:
function CheckForGame: Boolean;
var
TPA: TPointArray;
begin
FindColors(TPA, 16777215, 0, 0, 437, 318)
If length(TPA) <500 then begin
result := false
end else begin
result := true;
end;
end;
我必须检查游戏是否已经开始“游戏领域的宝石”如果没有那么停止,如果他们超过500则他们应该开始游戏。
program Diamond_Minder;
var
T: Boolean;
const
Mode = 1; //Can be set to 1 or 2. Im not sure what is fastes :P
procedure WaitRR(MinWait, MaxWait: Integer);
begin
Wait(MinWait + Random(MaxWait - MinWait));
end;
function CheckForGame: Boolean;
var
TPA: TPointArray;
begin
FindColors(TPA, 16777215, 0, 0, 437, 318)
If length(TPA) < 500 then begin
result := false
end else begin
result := true;
end;
end;
procedure WaitForCleared;
var
TPA: TPointArray;
BX, NX: Integer;
begin
Wait(100);
Repeat
FindColors(TPA, 16777215, 0, 0, 437, 318)
BX := Length(TPA);
WaitRR(50, 75);
FindColors(TPA, 16777215, 0, 0, 437, 318)
NX := Length(TPA);
Until(BX = NX);
end;
procedure StartNewGame;
var
TPA, TPA2: TPointArray;
x, y, LX, LY: Integer;
begin
WaitRR(2000, 2100);
WaitForCleared;
FindColors(TPA, 2986564, 181, 349, 266, 364)
MouseBox(181, 349, 266, 364)
FindColors(TPA2, 2986564, 181, 349, 266, 364)
WaitRR(10, 20);
LX := Length(TPA);
LY := Length(TPA2);
if LX > LY then begin
Writeln('Started a new game');
end else begin
writeln('Could not find the start button stopping the script');
TerminateScript;
end;
GetMousePos(x, y);
ClickMouse(x, y, True);
MoveWindMouse(140 + Random(300), 0 + random(320), 0, 0);
While InRange(LX, 100, 500) do begin
FindColors(TPA, 16777215, 214, 57, 485, 328);
LX := Length(TPA);
Writeln(Lx)
end;
Writeln(1);
WaitRR(850, 950);
end;
//Default: GetBoxBounds(154, 18, 185, 49, 34, 34, 1, 1)
{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Description: Turn a big box in to small boxes and return the given box as a TBox
xs, ys, xe, ye: The cordinates of the big box.
CordsPerBoxX, PixelsPerBoxY: Number of coordinates between the small boxes.
BoxX, BoxY: The returned boxes. example: (1, 1)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}
function GetBoxBoundsEx (xs, ys, xe, ye, CordsPerBoxX, CordsPerBoxY, BoxX, BoxY: Integer): TBox;
begin
result := IntToBox(xs + (CordsPerBoxX * (BoxX - 1)), ys + (CordsPerBoxY * (BoxY - 1)), xe + (CordsPerBoxX * (BoxX - 1)), ye + (CordsPerBoxY * (BoxY - 1)));
end;
function GetBoxBounds (BoxX, BoxY: Integer): TBox;
begin
result := IntToBox(214 + (34 * (BoxX - 1)), 57 + (34 * (BoxY - 1)), 247 + (34 * (BoxX - 1)), 90 + (34 * (BoxY - 1)));
end;
procedure GetCoords (var xs, ys, xe, ye: Integer; BoxX, BoxY: Integer);
begin
xs := GetBoxBounds(BoxX, BoxY).x1;
ys := GetBoxBounds(BoxX, BoxY).y1;
xe := GetBoxBounds(BoxX, BoxY).x2;
ye := GetBoxBounds(BoxX, BoxY).y2;
end;
function CompareColors(i, e, i2, e2, i3, e3, i4, e4, ColorA: Integer; Var Colors: TIntegerArray; var TBFrom: TPoint; var TBTo: TBox): Boolean;
var
xs, ys, xe, ye, x, y: Integer;
begin
//1st (i)
GetCoords(xs, ys, xe, ye, i, e);
if FindColorTolerance(x, y, Colors[ColorA], xs, ys, xe, ye, 2) then begin
//2nd (i2)
GetCoords(xs, ys, xe, ye, i + i2, e + e2);
if FindColorTolerance(x, y, Colors[ColorA], xs, ys, xe, ye, 2) then begin
//4rd (i3)
GetCoords(xs, ys, xe, ye, i + i3, e + e3);
if FindColorTolerance(x, y, Colors[ColorA], xs, ys, xe, ye, 2) then begin
TBFrom := Point(x, y);
//3rd (i4)
GetCoords(xs, ys, xe, ye, i + i4, e + e4);
TBTo := Box(xs, ys, xe, ye);
Result := True;
exit;
end;
end;
end;
end;
function GetOptions (Colors: TIntegerArray; var TBFrom: TPoint; var TBTo: TBox): Boolean;
var
i, e, c, H: Integer;
begin
H := High(Colors);
for c := 0 to H do begin //Colors
for e := 1 to 8 do begin //Y row
for i := 1 to 8 do begin //X row
//Pattern 1
if CompareColors(i, e, 1, 0, 3, 0, 2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 1');
exit;
//Pattern 2
end else if CompareColors(i, e, -1, 0, -3, 0, -2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 2');
exit;
//Pattern 3
end else if CompareColors(i, e, 0, -1, -1, -2, 0, -2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 3');
exit;
//Pattern 4
end else if CompareColors(i, e, 0, -1, 1, -2, 0, -2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 4');
exit;
//Pattern 5
end else if CompareColors(i, e, 0, -2, 1, -1, 0, -1, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 5');
exit;
//Pattern 6
end else if CompareColors(i, e, 0, 1, 1, 2, 0, 2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 6');
exit;
//Pattern 7
end else if CompareColors(i, e, 0, 1, -1, 2, 0, 2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 7');
exit;
//Pattern 8
end else if CompareColors(i, e, 1, 0, 2, -1, 2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 8');
exit;
//Pattern 9
end else if CompareColors(i, e, 1, 0, 2, 1, 2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 9');
exit;
//Pattern 10
end else if CompareColors(i, e, 2, 0, 1, 1, 1, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 10');
exit;
//Pattern 11
end else if CompareColors(i, e, 2, 0, 1, -1, 1, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 11');
exit;
//Pattern 12
end else if CompareColors(i, e, 0, 1, 0, 3, 0, 2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 12');
exit;
//Pattern 13
end else if CompareColors(i, e, -1, 0, -2, -1, -2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 13');
exit;
//Pattern 14
end else if CompareColors(i, e, 0, -1, 0, -3, 0, -2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 14');
exit;
//Pattern 15
end else if CompareColors(i, e, 0, 2, -1, 1, 0, 1, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 15');
exit;
end else if CompareColors(i, e, -1, 0, -2, 1, -2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 16');
exit;
end;
end;
end;
end;
writeln('No more options. Starting a new game');
WaitForCleared;
StartNewGame;
end;
procedure ClickBoxes;
var
x, y: Integer;
TBFrom: TPoint;
TBTo: TBox;
begin
if Mode = 1 then WaitForCleared;
// | Grey | | Red | |Purple| |Green| | Blue | | Teal| |Yellow|
if GetOptions([5918276, 6119398, 5450823, 4806974, 6703944, 8485181, 5171947, 8089653, 4538462], TBFrom, TBTo) then begin
MoveMouse(TBFrom.X, TBFrom.Y);
if Mode = 2 then WaitForCleared;
ClickMouse(TBFrom.X, TBFrom.Y, True);
MouseBox(TBTo.x1, TBTo.y1, TBTo.x2, TBTo.y2);
GetMousePos(x, y);
ClickMouse(x, y, True);
end;
end;
begin
ClearDebug;
Writeln('Welcome to sjespers Diamond Minder');
if CheckForGame = false then begin
writeln('Did not detect the game. Remember to drag the target to the game. If its not working then try to refresh the game');
TerminateScript;
end else begin
writeln('Found the game. Starting to make you some tokens');
end;
repeat
ClickBoxes;
until(false)
end.
答案 0 :(得分:0)
我不知道您的程序输出是什么,但我尝试修复代码中的一些错误。
我保留原始代码行包含注释错误。
program Diamond_Minder;
//var
// T: Boolean;
const
Mode = 1; //Can be set to 1 or 2. Im not sure what is fastes :P
procedure WaitRR(MinWait, MaxWait: Integer);
begin
Wait(MinWait + Random(MaxWait - MinWait));
end;
function CheckForGame: Boolean;
var
TPA: TIntArray;
x, y : Longint;
begin
FindColors(x,y,TPA, 0, 0, 437, 318);
//FindColors(TPA, 16777215, 0, 0, 437, 318);
If length(TPA) < 500 then begin
result := false
end else begin
result := true;
end;
end;
procedure WaitForCleared;
var
TPA: TIntArray;
BX, NX: Integer;
x, y : Longint;
begin
Wait(100);
Repeat
FindColors(x,y, TPA, 0, 0, 437, 318);
//FindColors(TPA, 16777215, 0, 0, 437, 318)
BX := Length(TPA);
WaitRR(50, 75);
FindColors(x,y,TPA, 0, 0, 437, 318);
//FindColors(TPA, 16777215, 0, 0, 437, 318)
NX := Length(TPA);
Until(BX = NX);
end;
procedure StartNewGame;
var
TPA, TPA2: TIntArray;
x, y, LX, LY: Integer;
begin
WaitRR(2000, 2100);
WaitForCleared;
FindColors(x,y,TPA, 181, 349, 266, 364);
//FindColors(TPA, 2986564, 181, 349, 266, 364)
MouseInBox(Box(181, 349, 266, 364));
//MouseBox(181, 349, 266, 364);
FindColors(x,y,TPA2, 181, 349, 266, 364);
//FindColors(TPA2, 2986564, 181, 349, 266, 364)
WaitRR(10, 20);
LX := Length(TPA);
LY := Length(TPA2);
if LX > LY then begin
Writeln('Started a new game');
end else begin
writeln('Could not find the start button stopping the script');
TerminateScript;
end;
GetMousePos(x, y);
ClickMouse(x, y, True);
MoveMouseBox(Box(140 + Random(300), 0 + random(320), 0, 0));
//MoveWindMouse(140 + Random(300), 0 + random(320), 0, 0);
While InRange(LX, 100, 500) do begin
//FindColors(TPA, 16777215, 214, 57, 485, 328);
FindColors(x, y, TPA, 214, 57, 485, 328);
LX := Length(TPA);
Writeln(Lx)
end;
Writeln(1);
WaitRR(850, 950);
end;
//Default: GetBoxBounds(154, 18, 185, 49, 34, 34, 1, 1)
{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Description: Turn a big box in to small boxes and return the given box as a TBox
xs, ys, xe, ye: The cordinates of the big box.
CordsPerBoxX, PixelsPerBoxY: Number of coordinates between the small boxes.
BoxX, BoxY: The returned boxes. example: (1, 1)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}
function GetBoxBoundsEx (xs, ys, xe, ye, CordsPerBoxX, CordsPerBoxY, BoxX, BoxY: Integer): TBox;
begin
result := IntToBox(xs + (CordsPerBoxX * (BoxX - 1)), ys + (CordsPerBoxY * (BoxY - 1)), xe + (CordsPerBoxX * (BoxX - 1)), ye + (CordsPerBoxY * (BoxY - 1)));
end;
function GetBoxBounds (BoxX, BoxY: Integer): TBox;
begin
result := IntToBox(214 + (34 * (BoxX - 1)), 57 + (34 * (BoxY - 1)), 247 + (34 * (BoxX - 1)), 90 + (34 * (BoxY - 1)));
end;
procedure GetCoords (var xs, ys, xe, ye: Integer; BoxX, BoxY: Integer);
begin
xs := GetBoxBounds(BoxX, BoxY).x1;
ys := GetBoxBounds(BoxX, BoxY).y1;
xe := GetBoxBounds(BoxX, BoxY).x2;
ye := GetBoxBounds(BoxX, BoxY).y2;
end;
function CompareColors(i, e, i2, e2, i3, e3, i4, e4, ColorA: Integer; Var Colors: TIntegerArray; var TBFrom: TPoint; var TBTo: TBox): Boolean;
var
xs, ys, xe, ye, x, y: Integer;
begin
//1st (i)
GetCoords(xs, ys, xe, ye, i, e);
if FindColorTol(x, y, Colors[ColorA], xs, ys, xe, ye, 2) then begin
//if FindColorTolerance(x, y, Colors[ColorA], xs, ys, xe, ye, 2) then begin
//2nd (i2)
GetCoords(xs, ys, xe, ye, i + i2, e + e2);
if FindColorTol(x, y, Colors[ColorA], xs, ys, xe, ye, 2) then begin
//if FindColorTolerance(x, y, Colors[ColorA], xs, ys, xe, ye, 2) then begin
//4rd (i3)
GetCoords(xs, ys, xe, ye, i + i3, e + e3);
if FindColorTol(x, y, Colors[ColorA], xs, ys, xe, ye, 2) then begin
//if FindColorTolerance(x, y, Colors[ColorA], xs, ys, xe, ye, 2) then begin
TBFrom := Point(x, y);
//3rd (i4)
GetCoords(xs, ys, xe, ye, i + i4, e + e4);
TBTo := Box(xs, ys, xe, ye);
Result := True;
exit;
end;
end;
end;
end;
function GetOptions (Colors: TIntegerArray; var TBFrom: TPoint; var TBTo: TBox): Boolean;
var
i, e, c, H: Integer;
begin
H := High(Colors);
for c := 0 to H do begin //Colors
for e := 1 to 8 do begin //Y row
for i := 1 to 8 do begin //X row
//Pattern 1
if CompareColors(i, e, 1, 0, 3, 0, 2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 1');
exit;
//Pattern 2
end else if CompareColors(i, e, -1, 0, -3, 0, -2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 2');
exit;
//Pattern 3
end else if CompareColors(i, e, 0, -1, -1, -2, 0, -2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 3');
exit;
//Pattern 4
end else if CompareColors(i, e, 0, -1, 1, -2, 0, -2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 4');
exit;
//Pattern 5
end else if CompareColors(i, e, 0, -2, 1, -1, 0, -1, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 5');
exit;
//Pattern 6
end else if CompareColors(i, e, 0, 1, 1, 2, 0, 2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 6');
exit;
//Pattern 7
end else if CompareColors(i, e, 0, 1, -1, 2, 0, 2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 7');
exit;
//Pattern 8
end else if CompareColors(i, e, 1, 0, 2, -1, 2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 8');
exit;
//Pattern 9
end else if CompareColors(i, e, 1, 0, 2, 1, 2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 9');
exit;
//Pattern 10
end else if CompareColors(i, e, 2, 0, 1, 1, 1, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 10');
exit;
//Pattern 11
end else if CompareColors(i, e, 2, 0, 1, -1, 1, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 11');
exit;
//Pattern 12
end else if CompareColors(i, e, 0, 1, 0, 3, 0, 2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 12');
exit;
//Pattern 13
end else if CompareColors(i, e, -1, 0, -2, -1, -2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 13');
exit;
//Pattern 14
end else if CompareColors(i, e, 0, -1, 0, -3, 0, -2, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 14');
exit;
//Pattern 15
end else if CompareColors(i, e, 0, 2, -1, 1, 0, 1, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 15');
exit;
end else if CompareColors(i, e, -1, 0, -2, 1, -2, 0, C, Colors, TBFrom, TBTo) then begin
Result := True;
Writeln('Clicked Pattern 16');
exit;
end;
end;
end;
end;
writeln('No more options. Starting a new game');
WaitForCleared;
StartNewGame;
end;
procedure ClickBoxes;
var
x, y: Integer;
TBFrom: TPoint;
TBTo: TBox;
begin
if Mode = 1 then WaitForCleared;
// | Grey | | Red | |Purple| |Green| | Blue | | Teal| |Yellow|
if GetOptions([5918276, 6119398, 5450823, 4806974, 6703944, 8485181, 5171947, 8089653, 4538462], TBFrom, TBTo) then begin
MoveMouse(TBFrom.X, TBFrom.Y);
if Mode = 2 then WaitForCleared;
ClickMouse(TBFrom.X, TBFrom.Y, True);
MouseInBox(Box(TBTo.x1, TBTo.y1, TBTo.x2, TBTo.y2));
//MouseBox(TBTo.x1, TBTo.y1, TBTo.x2, TBTo.y2);
GetMousePos(x, y);
ClickMouse(x, y, True);
end;
end;
begin
ClearDebug;
Writeln('Welcome to sjespers Diamond Minder');
if CheckForGame = false then begin
writeln('Did not detect the game. Remember to drag the target to the game. If its not working then try to refresh the game');
TerminateScript;
end else begin
writeln('Found the game. Starting to make you some tokens');
end;
repeat
ClickBoxes;
until(false)
end.
答案 1 :(得分:-1)
在数组上调用长度是Delphi扩展。 TP仅允许字符串上的长度。我不知道scardivi是什么。
你还没有为TPointArray提供定义。