SRL Archive - OSR Help

Type Mismatch


King

2013-03-30 23:23:07


How do I fix this? Basically I want the Point R to be the middle of my ATPA[k] That way I can move to that point, check for uptext then click the rock if it is indeed there, but Im lost..

Code
Function FindRocks: Boolean;
Var
TPA : TPointArray;
ATPA : T2DPointArray;
I, X, Y, K : Integer;
R:TPoint;

begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 0.19);
if FindColorsSpiralTolerance(X, Y, TPA, 4224658, MMX1, MMY1, MMX2, MMY2, 13) then
begin
if (Length(TPA) >= 5) then
begin
ATPA := TPAtoATPAEx(TPA, 15, 15);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
for i := Low(ATPA) to High(ATPA) do
for k := Low(ATPA[i]) to High(ATPA[i]) do
begin
if GetArrayLength(ATPA[i][k]) > 5 then
begin
R := MiddleTPA(ATPA[i][k]);

serajin

2013-03-30 23:27:04

You would need to use a TPointArray, and grab the middle with Middle(TPA). And if I am not mistaken, your R variable, would have to also be an Array.


Atpa := TPAtoATPAEx(Tpa, width, height);
for i := 0 to High(atpa) do
begin
if Length(atpa) > 5 then
begin
l := getarraylength(Result);
SetArrayLength(Result, l+1);
Result[l] := MiddleTpa(atpa[i]);
end;
end;

Le Jingle

2013-03-30 23:31:28

In the inner nested loop (the for k loop), you are going through TPoint types, not TPointArrays as in the outer for i loop.

Thus, the MiddleTPA function call is taking in a TPoint type and therefore gives you the error of a type mismatch (is supposed to take a TPointArray type argument)

Cheers,
Le Jingle

King

2013-03-30 23:32:55

From: Le Jingle
In the inner nested loop (the for k loop), you are going through TPoint types, not TPointArrays as in the outer for i loop.

Thus, the MiddleTPA function call is taking in a TPoint type and therefore gives you the error of a type mismatch (is supposed to take a TPointArray type argument)

Cheers,
Le Jingle


Okay, how do I find the middle of that then? I understand what you are saying :P

Le Jingle

2013-03-30 23:35:49

From: SRLKing
Okay, how do I find the middle of that then? I understand what you are saying :P


Use one loop, the for i loop and exclude the for k loop!
(Sometimes the solution is easier than you think ;])

King

2013-03-30 23:42:45

From: Le Jingle
Use one loop, the for i loop and exclude the for k loop!
(Sometimes the solution is easier than you think ;])


okay! Thanks :P

King

2013-03-31 00:19:20

@Le Jingle will you TV me, I need some help, Im beating my head on the floor pm me.