SRL Archive - OSR Help

Help for a coal miner


themaster999

2012-07-06 00:52:58

I have made a coal miner that i want to repeat the mining process until the inventory is full but it only mines one ore then starts clicking randomly on the rest of the screen. I am new to scripting and when i am mining i get attacked so i don't know if that has something to do with it or what.


Function GetOre:Boolean;
var
x, y, PlusOne, OreCounter:Integer;
Begin
PlusOne:= InvCount + 1;
x:=MSCX;
y:=MSCY;
If FindColorSpiral(x, y, oalColor, MSX1, MSY1, MSX2, MSY2) Then
Begin
Writeln('found one');

Case Random(2) Of
0: Mouse(x, y, 5, 5, True);
1: Begin
Mouse(x, y, 5, 5, False);
WaitOption('ine', 500);
End;
End;

Flag;
Repeat
MarkTime(OreCounter);
Antiban;
Wait(1000);
If InvCount=Plusone Then
Writeln('got one');
Until (Invcount=plusone) or (TimeFromMark(OreCounter) > 10000)
end;
end;


That is my code i am using and then i have the GetOre function on a repeat in the final part of the script. If anyone knows why it will only mine once then start randomly clicking that would be great!

EtherFreak

2012-07-06 01:40:03

could you post your entire script? It may help to determine the issue point. I dont think the issue is in what you posted (could use some cleaning up though such as non static wait times, and failsafes). I am wondering what your antiban is doing, or if you are not entering your repeat until loop.

themaster999

2012-07-06 11:18:37

I took out the Antiban and it was working a little better but it still misclicked sometimes and then it would just stand until i manuallly clicked a new rock. I have only worked on the mining part so far so here is the full part of my script.

**********************************************************************************

{$i SRL\SRL.simba}
Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := ''; // Character Name
Pass := ''; // Character Pass
Pin := ''; // Character Pin
Nick := ''; // Character Nickname
Active := True; // Use player in script?
end;
end;
var
Coal:Integer;

————————————————————————————————————————
function oalColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(16.67, 3.45);
if not (FindColorsTolerance(arP, 921359, MSX1, MSY1, MSX2, MSY2, 1)) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
Result := arC;
//Writeln('AutoColor = ' + IntToStr(arC));
Break;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;
————————————————————————————————————————
Function GetOre:Boolean;
var
x, y, PlusOne, OreCounter:Integer;
Begin
PlusOne:= InvCount + 1;
x:=MSCX;
y:=MSCY;
If FindColorSpiral(x, y, oalColor, MSX1, MSY1, MSX2, MSY2) Then
Begin
Writeln('found one');
Mouse(x, y, 5, 5, True);

Flag;
Repeat
MarkTime(OreCounter);
Wait(1000);
If InvCount=Plusone Then
Writeln('got one');
Until (Invcount=plusone) or (TimeFromMark(OreCounter) > 10000)
end;
end;
————————————————————————————————————————
begin
SetupSRL;
Repeat
GetOre;
Until (InvFull)
end.
**********************************************************************************


If there is a better way to find the rocks I am open to any suggestions.

Wreck

2012-07-06 11:25:16

Write a "IsMining" function that you can check whether you are animating or not by using PixelShift then do something like

if IsMining then
wait(50)
else
GetOre;

themaster999

2012-07-06 11:40:11

Thanks I have it working better now!