Okay, so, for my AutoMiner, i wanted to make it move to the mining symbol (getting it near the center) and then from there move to the rocks it needed to. (Either copper, tin, iron, or gold.) To do this, i created bitmaps of the rocks on the minimap, and used FindDeformed to locate them. It all works fine, except that FindDeformed takes too long to find them, that RS logs out from not moving or clicking anything.
From what i understand, FindDeformed searches for the bitmap, then lowers the tolerance, then searches, then lowers, and so on until it finds the bitmap. If i could alter FindDeformed to do something like click a gametab between searches, then it wouldn't log me out. If i did so, i'd have to put the altered version in my script. When i tried to make it like so:
SCAR Code:
function FindDeformed(var Xoff, Yoff: Integer; BMP, a, b, c, d: Integer):
Boolean;
var
acc, ref: Extended;
XT, YT, times, tol: Integer;
begin
ref := 0.9;
tol := 0;
for times := 1 to 50 do
GameTab(2); // This is
GameTab(4); // what I
Wait(700+random(500)); // added
begin
FindDeformedBitmapToleranceIn(BMP, XT, YT, a, b, c, d, tol, 2, True, acc);
if (acc >= ref) then
begin
Xoff := XT;
YOff := YT;
Result := True;
Exit;
end;
if times mod 5 = 0 then
begin
ref := ref - 0.1;
tol := tol + 10;
end;
Wait(1);
end;
end;
And it compiled, but when i ran it all it did was the gametabs, and then gave me some access error thing. (I don't remember exactly what it said.) Could anyone explain to me what I did wrong, or what i should do instead?
Also, i tried creating a DTM of the rocks. I made the parent point the ground near the rocks, with max tolerance, and then made the other points near the center of each rock. It worked perfectly, but then when i changed worlds the colors changed (which i was unaware that they did that, i thought only the roads did
) so i'm guessing i can't use that then. Currently in my script is checks for the DTM fives times, and if it still doesn't find it it does FindDeformed as a last resort (which has the above-mentioned problem)
Could anyone help me out?
Edit: Here's what the error was
"[Runtime Error] : Exception: Access violation at address 006A975B in module 'scar.exe'. Read of address 00000000 in line 114 in script C:\ProgramFiles\SCAR3.06\Scripts\MyAutoMiner\Rimmi ngtonAutoMinerV0.6scar"