Richard
2008-05-12 13:06:38
This is just a basic function that I made for my smelter, just so it could find the furnace more reliably than FindObjTPA. And I thought it might be useful to people making smelters, just incase they don't know TPAs. Its my first proper TPA usage so don't insult it too much :p
Example of how quickly it finds it:
Thats one of the slower times, it once did it in 138 I think, somewhere near that.
NOTE: I've only testing in Al Kharid, I think all furnaces are the same, but if they aren't this may only work there.
Thanks to Hermpie for helping me learn TPAs.
Function HandleFurnace:Boolean;
Var
TPA: TPointArray;
Temp: T2DPointArray;
h, x, y, MouseSpeed2, z, t, CTS: Integer;
begin
If not LoggedIn then Exit;
MouseSpeed2 := MouseSpeed;
MouseSpeed := 25;
t := GetSystemTime;
CTS := ColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(x, y, TPA, 2500137, MSX1, MSY1, MSX2, MSY2, 5);
Temp := TPAtoATPAex(TPA, 40, 40);
SortATPASize(Temp, True);
h := High(Temp);
For z := 0 to h do
Begin
If Length(z) >= 10 then //10 a good ammount?
Continue;
MiddleTPAex(Temp[z], x, y);
MMouse(x, y, 5, 5);
Result := IsUpText('melt');
If Result then
Begin
WriteLN('Found the furnace in '+IntToStr((GetSystemTime) - t)+' msecs');
break;
end;
Wait(100);
end;
If Result then
Begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
end;
If Not Result then
WriteLN('Couldn'#39't find a furnace');
MouseSpeed := MouseSpeed2;
ColorToleranceSpeed(CTS);
end;Example of how quickly it finds it:
Found the furnace in 477 msecsThats one of the slower times, it once did it in 138 I think, somewhere near that.
NOTE: I've only testing in Al Kharid, I think all furnaces are the same, but if they aren't this may only work there.
Thanks to Hermpie for helping me learn TPAs.