SRL Archive - OSR Help

help with procedure


westkevin12

2013-05-01 01:18:12

thanks problem solved!

bud_wis_er_420

2013-05-01 01:52:24

Not 100%, but I think you need to use SplitTPA to transfer a variable. Like this…
ATPA := SplitTPA(TPA, 1); //ATAP is –> ATPA: T2DPointArray;
otherwise nothing happens with that piece of code.
SplitTPA() Splits TPAs down to sizes. So lets say iron ore is roughly 20 pixels across(Square) You would use ATPA := SplitTPA(TPA, 20); and if it was say: 20 from left 2 right and 10 from top to bottom, yo would use ATPA := SplitTPAEx(TPA, 20, 10);

middletpa only give you the middle pt of the tpa. So you are not getting your TPAs accurate.


SMART_DebugATPA(false, ATPA); This will alow you to see what your TPAs look like on screen. It draws a box around the TPA.

Here is my ACA function, Look over it to see how things work. Hope this helped you.
//Like FindColorsTolerance but with CT2
function FindACA(Col, Tol: Integer; Hue, Sat: Extended; Uptext: TStringArray; x1, y1, x2, y2, Dist: Integer): Boolean;
var
i, TPAL, tmpCTS: integer;
P: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
TVA: TVariantArray;
begin
if CheckLogin then Exit;
Result := False;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue, Sat);
WriteDebug('Color: ' + IntToStr(Col));
WriteDebug('Tol: ' + IntToStr(Tol));
WriteDebug('Hue: ' + FloatToStr(Hue));
WriteDebug('Sat: ' + FloatToStr(Sat));
WriteDebug('Box: (' + IntToStr(x1) +', ' + IntToStr(y1) +', ' + IntToStr(x2) +', ' + IntToStr(y2) +')' );

if Debug then SMART_DrawBox(IntToBox(x1, y1, x2, y2));
if not FindColorsTolerance(TPA, Col, x1, y1, x2, y2, Tol) then
begin
WriteDebug('Failed to find color');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
SMART_ClearCanvas;
Exit;
end;

WriteDebug('Drawing on found colors');
if Debug then SMART_DrawDotsEx(False, TPA, clRed);
ATPA := TPAToATPA(TPA, Dist); //Overlaps
//ATPA := SplitTPA(TPA, 1); //Dose not overlap
SortATPAFrom(ATPA, Point(MSCX, MSCY));
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if Debug then SMART_DebugATPA(false, ATPA);
if DebugWait then
begin
WriteDebug('Waiting 2sec');
wait(2000);
end;

TPAL := High(ATPA);
for i := 0 to TPAL do
begin
P := MiddleTPA(ATPA[i]);
MMouse(P.x, P.y, 2, 2);
TVA := [Uptext]
if WaitFuncEx('FindTextAdv', TVA, RandomRange(100,150),RandomRange(900,1000)) then
begin;
Result := True;
Break;
end else WriteDebug('Didn''t find uptext: ' + Uptext[0]);
if Debug then PaintCross(P.x, P.y, clRed);
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if Debug then SMART_ClearCanvas;
end;

bud_wis_er_420

2013-05-01 03:03:00

Try this
TPAL := High(ATPA);
for i := 0 to TPAL do

and next time make a new post. Your Lucky, I don't usually reread a post and I just realized you edited your first post with new code and asked a new question.

westkevin12

2013-05-01 03:11:46

From: bud_wis_er_420
Try this
TPAL := High(ATPA);
for i := 0 to TPAL do

and next time make a new post. Your Lucky, I don't usually reread a post and I just realized you edited your first post with new code and asked a new question.

thanks