CowFish
07-21-2012, 02:23 AM
in my script im using tpas to try and find trees, and while it is finding them i think there is something wrong with the way i coded it because the mouse jumps to each object many many times and eventually (sometimes after a matter of minutes or sometimes never) actually clicks the object. i'll attach my procedure but I'd love to fix this because it's really pissing me off.. sorry about standards but this is kind of a quick and dirty script. btw i can't use uptext so that's why i have a dtm to figure out if its the right object. also i know findtree doesn't need to be a function, not sure why I made it one.
function ismagic: boolean;
var
updtm,x ,y : integer;
begin
updtm := DTMFromString('mlwAAAHicY2dgYIgH4kwgLgXiSiDuBOKpQD wXiIWAWAyIxYFYBIgFoWxRIGa6eYOB/e4tBs77Nxi4Hj0C8m8xMN++zcD79CkDP1AeF2bEg6EAANguEL0 =');
if FindDTM(updtm, x, y, 0, 0, 500, 500) then
begin
Result := True;
end;
freedtm(updtm);
end;
function findtree: boolean;
var x,y: integer;
TPA: array of tpoint;
atpa: t2dpointarray;
i: integer;
begin
FindColorsSpiralTolerance(x,y, TPA,10672344, MSX1, MSY1, MSX2, MSY2, 15);
begin
ATPA := TPAtoATPAEx(TPA, 10, 30);
SortATPASize(ATPA,True);
for i:=0 to High(ATPA) do
begin
middletpaex(atpa[i], x,y);
mmouse(x,y,1,1);
if ismagic then
begin
Mouse(x, y,1,1,True);
writeln('tree found and clicked');
Result := true;
break;
end;
end;
end;
end;
procedure choppinloop;
var
x,y:integer;
begin
findtree;
repeat
wait(100);
checkbob;
until not IsChopping or (fullinvy);
end;
MAIN LOOP
repeat
repeat
choppinloop;
until fullinvy
if fullinvy then
repeat
droplogs;
checkbob;
until not ExistsItemz(1);
if not fullinvy then
begin
choppinloop;
end;
until(IsFKeyDown(12));
function ismagic: boolean;
var
updtm,x ,y : integer;
begin
updtm := DTMFromString('mlwAAAHicY2dgYIgH4kwgLgXiSiDuBOKpQD wXiIWAWAyIxYFYBIgFoWxRIGa6eYOB/e4tBs77Nxi4Hj0C8m8xMN++zcD79CkDP1AeF2bEg6EAANguEL0 =');
if FindDTM(updtm, x, y, 0, 0, 500, 500) then
begin
Result := True;
end;
freedtm(updtm);
end;
function findtree: boolean;
var x,y: integer;
TPA: array of tpoint;
atpa: t2dpointarray;
i: integer;
begin
FindColorsSpiralTolerance(x,y, TPA,10672344, MSX1, MSY1, MSX2, MSY2, 15);
begin
ATPA := TPAtoATPAEx(TPA, 10, 30);
SortATPASize(ATPA,True);
for i:=0 to High(ATPA) do
begin
middletpaex(atpa[i], x,y);
mmouse(x,y,1,1);
if ismagic then
begin
Mouse(x, y,1,1,True);
writeln('tree found and clicked');
Result := true;
break;
end;
end;
end;
end;
procedure choppinloop;
var
x,y:integer;
begin
findtree;
repeat
wait(100);
checkbob;
until not IsChopping or (fullinvy);
end;
MAIN LOOP
repeat
repeat
choppinloop;
until fullinvy
if fullinvy then
repeat
droplogs;
checkbob;
until not ExistsItemz(1);
if not fullinvy then
begin
choppinloop;
end;
until(IsFKeyDown(12));