SRL Archive - OSR Help

script repeating action too many times


mika

2011-02-16 17:14:15

The problem is after MineMith cant find the colors(BTW iw ill change to findobject instead of find color later) of the rock to mine it walks to the coal, but after not find the color it walks again and again until it does it no more than 8 times(thats why i have the # of wait so it wont try mining more rocks then there are) I want the script to only walk to coal once not several times & after walking the to mine the coal(i already have procedure ready for mining coal)
BTW this isn't the entire script only the part im stuck on.

procedure MineMith;
var
x, y : Integer;
begin
if not LoggedIn then Exit;
if FindColorTolerance(x, y, 7425099, MSX1, MSY1, MSX2, MSY2, 10) then // If the color (7425099) is found, the coordinates of where it was found is stored in the variables (x, y).
Mouse(x, y, 5, 5, True) // This moves and clicks the mouse to x, y; 4, 4 is the randomness on x, y
else

begin
Wait(1000); // Remember 1000ms = 1s
MakeCompass('n');
Writeln('First FindColor failed, trying second...');
if FindColorTolerance(x, y, 7819343, MSX1, MSY1, MSX2, MSY2, 10) then
Mouse(x, y, 4, 2, True) // This moves AND left clicks the mouse with randomness 4, 4; 'True' = Left click; 'False' = Right click
else

begin
Wait(2000);
Writeln('Second FindColor failed, trying third...');
if FindColorTolerance(x, y, 6505026, MSX1, MSY1, MSX2, MSY2, 15) then
Mouse(x, y, 4, 4, True)
else

begin
Wait(2000);
Writeln('Third FindColor failed, trying forth...');
if FindColorTolerance(x, y, 6636611, MSX1, MSY1, MSX2, MSY2, 15) then
Mouse(x, y, 4, 4, True)
else

begin
Wait(1560);
WalkToCoal;
Writeln('Forth FindColors failed, logging out');
Writeln('walk to coal'); // This is pretty straight forward, it logs your player out
end;
end;
end;
end;
end; // There are so many 'end's because each begin has to have an end, otherwise you will get an "Identifier expected..." error

function InvyFulBankIt: Boolean;
var
x, y : Integer;
begin
if not LoggedIn then Exit;
if (InvFull) then
if FindObjCustom(x, y, ['eposit', 'ank'], [5791845, 6121068], 5) then//Notice how I used "[]".
begin
Writeln('Found deposit box!');
Mouse(x, y, 56, 6, True);//MMouse and uptext check isn't needed becaue it's already built into FindObjCustom, understand?
Result := True;//Returns true of the copper ore was clicked.
end else
//Find deposit box procedure

end;


procedure RepeatMineMith;
var
numberOfWaits: Integer;
begin // Although 'repeat' acts like a 'begin', 'begin' is still needed here to signal the start of the procedure
repeat
Wait(10195);
MineMith;
Inc(numberOfWaits); // The Inc() command simply increases the var numberOfWaits by 1
Writeln('We have mined ' + IntToStr(numberOfWaits) + ' times');
until(InvFull) or (numberOfWaits = 8);
Wait(1095 + random(400));
InvyFulBankIt;
end;

begin
ClearDebug;
SetupSRL;
DeclarePlayers; // Calls the procedure, you can't forget this!
LoginPlayer; // You want your player to login, right?
RepeatMineMith;
end.

**BANNED The Man

2011-02-16 17:21:55

Ok, so I don't really understand your question but here is a nicer version of your MineMith procedure
procedure MineMith;
var
x, y, i : Integer;
Colors : TIntegerArray;
begin
Colors := [7425099, 7819343, 6505026, 6636611];
if not LoggedIn then Exit;
for i := 0 to Colors do
begin
if FindColorTolerance(x, y, i, MSX1, MSY1, MSX2, MSY2, 10) then // If the color (7425099) is found, the coordinates of where it was found is stored in the variables (x, y).
Mouse(x, y, 5, 5, True) // This moves and clicks the mouse to x, y; 4, 4 is the randomness on x, y
else
begin
Wait(1560);
WalkToCoal;
Writeln('Forth FindColors failed, logging out');
Writeln('walk to coal'); // This is pretty straight forward, it logs your player out
end;
end;
end;

-Boom

Echo_

2011-02-16 21:10:15

This is your problem:
or (numberOfWaits = 8);

mika

2011-02-16 21:50:48

once again i have been misunderstood.
The red flag shows where the character is walking.
In the first picture he is going from the left area to the right that is good exactly what i want.
In the second picture he is attempting to go to the right area again even though he is there, he is doing that because he cannot find any mith rocks.
the problem is he keeps trying to go to the right area many times.
I need him to go to the area on the right only once.

Echo_

2011-02-16 22:38:22

From: mika
once again i have been misunderstood.
The red flag shows where the character is walking.
In the first picture he is going from the left area to the right that is good exactly what i want.
In the second picture he is attempting to go to the right area again even though he is there, he is doing that because he cannot find any mith rocks.
the problem is he keeps trying to go to the right area many times.
I need him to go to the area on the right only once.


After walking to the coal when the script cannot find any mithril ore, the procedure needs to exit the loop.

procedure MineMith;
var
x, y : Integer;
begin
if not LoggedIn then Exit;
if FindColorTolerance(x, y, 7425099, MSX1, MSY1, MSX2, MSY2, 10) then
Mouse(x, y, 5, 5, True);
else

begin
Wait(1000);
MakeCompass('n');
Writeln('First FindColor failed, trying second...');
if FindColorTolerance(x, y, 7819343, MSX1, MSY1, MSX2, MSY2, 10) then
Mouse(x, y, 4, 2, True);
else

begin
Wait(2000);
Writeln('Second FindColor failed, trying third...');
if FindColorTolerance(x, y, 6505026, MSX1, MSY1, MSX2, MSY2, 15) then
Mouse(x, y, 4, 4, True);
else

begin
Wait(2000);
Writeln('Third FindColor failed, trying forth...');
if FindColorTolerance(x, y, 6636611, MSX1, MSY1, MSX2, MSY2, 15) then
Mouse(x, y, 4, 4, True);
else

begin
Wait(1560);
WalkToCoal;
Writeln('Forth FindColors failed, logging out');
Writeln('walk to coal');
Exit;//breaks out of the repeat - until statement in the main loop
end;
end;
end;
end;
end;

mika

2011-02-17 16:48:05

the exit did not fix the problem

Echo_

2011-02-17 17:00:28

Alright, post your WalkToCoal procedure then :duh:

mika

2011-02-17 18:03:42

walk to coal procedure

function WalkToCoal: Boolean;
begin
If RadialWalkTolerance(7697271 , 65, 110, 73, 5, 5, 10) then // 10 is the tolerance
begin
Writeln('Walking to coal is working fine!');
Exit;
end else
Writeln(' Walking to coal error finding road using backup method.)');
begin
Wait(2000 + Random(1100))
Mouse(692,81,2,2,true);
Writeln('Successfully completed backup walking.');
end
Writeln('Walked to coal!');
end;