Jump to content
jonas9513

Line 19: Type mismatch.

Recommended Posts

Any help?

 

Type mismatch is a compile error meaning that you are comparing two different & non-compatible things. An "if" statement should result to a boolean (true or false) if true, do something, if false don't.

Therefore I don't know what your function "length(...)" is and I don't know what TPA variable type is either.

I can't help unless you post the entire code, or at least all the code that is relevant.

Link to comment
Share on other sites

Type mismatch is a compile error meaning that you are comparing two different & non-compatible things. An "if" statement should result to a boolean (true or false) if true, do something, if false don't.

Therefore I don't know what your function "length(...)" is and I don't know what TPA variable type is either.

I can't help unless you post the entire code, or at least all the code that is relevant.

 

Hello BryceTheCoder,

 

The script is taken from here: http://forums.scar-divi.com/showthread.php?t=1195

 

program Diamond_Minder;

var
 T: Boolean;

const
 Mode = 1; //Can be set to 1 or 2. Im not sure what is fastes 

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.

 

I tried to rework it like this but still aint working:

program Diamond_Minder;

//var
//  T: Boolean;

const
 Mode = 1; //Can be set to 1 or 2. Im not sure what is fastes 

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.

Link to comment
Share on other sites

function SomeFunction: Boolean;
var
 TPA: TPointArray;
begin
 FindColorEx(TPA, 16777215, 0, 0, 437, 318);
 If length(TPA)<500 then begin
   result := false
 end else begin
   result := true;
 end;
end;

begin
 SomeFunction; 
end.

 

Fixed to compile

 

Use FindColorsEx for that purpose as when you look at FindColors code hints that has a different purpose. You're also missing a semi colon at the end of the line.

Edited by Wanted
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...