SRL Archive - OSR Help

Help with wait function


Thief

2013-05-01 09:27:07

I'm trying to use a simple wait function while my character climbs an obstacle, so he doesn't try and go onto the next procedure.
The annoying thing is, sometimes it works and sometimes it ignores the wait completely, and I have no idea why :duh:

The wait is right at the end of the code.


Function FindShortcut:boolean;
var
PathTPA, WallTPA:TPointArray;
PathATPA:T2DPointArray;
PathBox:TBox;
i, r, counter:integer;
begin
if not(loggedin) then
exit;
Wait(RandomRange(2000, 200));
SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 0.43);
if FindColorsSpiralTolerance(MSX1, MSY1, PathTPA, 4413280, MSX1, MSY1, MSX2, MSY2, 20) then
begin
PathATPA := SplitTPAEx(PathTPA, 25, 25);
SortATPASize(PathATPA, True);
for i := 0 to high(PathATPA) do
begin
PathBox := GetTPABounds(PathATPA[i]);
SetColorSpeed2Modifiers(0.20, 3.85);
if FindColorsSpiralTolerance(MSX1, MSY1, WallTPA, 12118515, PathBox.X1, Pathbox.Y1, Pathbox.X2, Pathbox.Y2, 10) then
Break;
if i = high(PathATPA) then
begin
writeln('Couldnt find wall color');
Terminatescript;
end;
end;
SetColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
marktime(counter);
while (not isuptext('wall')) do
begin
r := random(length(WallTPA));
mmouse(WallTPA[r].x, WallTPA[r].y, 2, 2);
wait(randomrange(200, 500));
if timefrommark(counter) > 10000 then
begin
writeln('couldnt find it');
Logout;
Terminatescript;
end;
end;
ClickMouse2(Mouse_left);
end;
Wait(RandomRange(7000, 1000)); [COLOR="#0000FF"]//This is my wait...... :([/COLOR]
end;

Ian

2013-05-01 09:58:16

I notice it's

Wait(RandomRange(7000, 1000)); //between 7 and 1 seconds
Did you mean it to be

Wait(RandomRange(7000, 10000)); //between 7 and 10 seconds
?

I'm just wondering because usually the smaller number is first.

Sjoe

2013-05-01 10:00:06

From: BMWxi
I notice it's

Wait(RandomRange(7000, 1000)); //between 7 and 1 seconds
Did you mean it to be

Wait(RandomRange(7000, 10000)); //between 7 and 10 seconds
?

I'm just wondering because usually the smaller number is first.


Good catch ;)

Thief

2013-05-01 10:06:44

Oh snap, I always thought the second number was random, while the first was the minimum wait time. Thanks!!!

Ian

2013-05-01 10:11:04

From: pure_thief
Oh snap, I always thought the second number was random, while the first was the minimum wait time. Thanks!!!


Np, glad I could help :)

westkevin12

2013-05-02 01:33:02

From: pure_thief
I'm trying to use a simple wait function while my character climbs an obstacle, so he doesn't try and go onto the next procedure.
The annoying thing is, sometimes it works and sometimes it ignores the wait completely, and I have no idea why :duh:

The wait is right at the end of the code.


Function FindShortcut:boolean;
var
PathTPA, WallTPA:TPointArray;
PathATPA:T2DPointArray;
PathBox:TBox;
i, r, counter:integer;
begin
if not(loggedin) then
exit;
Wait(RandomRange(2000, 200));
SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 0.43);
if FindColorsSpiralTolerance(MSX1, MSY1, PathTPA, 4413280, MSX1, MSY1, MSX2, MSY2, 20) then
begin
PathATPA := SplitTPAEx(PathTPA, 25, 25);
SortATPASize(PathATPA, True);
for i := 0 to high(PathATPA) do
begin
PathBox := GetTPABounds(PathATPA[i]);
SetColorSpeed2Modifiers(0.20, 3.85);
if FindColorsSpiralTolerance(MSX1, MSY1, WallTPA, 12118515, PathBox.X1, Pathbox.Y1, Pathbox.X2, Pathbox.Y2, 10) then
Break;
if i = high(PathATPA) then
begin
writeln('Couldnt find wall color');
Terminatescript;
end;
end;
SetColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
marktime(counter);
while (not isuptext('wall')) do
begin
r := random(length(WallTPA));
mmouse(WallTPA[r].x, WallTPA[r].y, 2, 2);
wait(randomrange(200, 500));
if timefrommark(counter) > 10000 then
begin
writeln('couldnt find it');
Logout;
Terminatescript;
end;
end;
ClickMouse2(Mouse_left);
end;
Wait(RandomRange(7000, 1000)); [COLOR="#0000FF"]//This is my wait...... :([/COLOR]
end;

try this out it will wait untill your not moving and not climbing an obstacle

Function FindShortcut:boolean;
var
PathTPA, WallTPA:TPointArray;
PathATPA:T2DPointArray;
PathBox:TBox;
i, r, counter:integer;
Pbox: Tbox
begin
if not(loggedin) then
exit;
PBox := IntToBox(206, 137, 309, 230);
Wait(RandomRange(2000, 200));
SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 0.43);
if FindColorsSpiralTolerance(MSX1, MSY1, PathTPA, 4413280, MSX1, MSY1, MSX2, MSY2, 20) then
begin
PathATPA := SplitTPAEx(PathTPA, 25, 25);
SortATPASize(PathATPA, True);
for i := 0 to high(PathATPA) do
begin
PathBox := GetTPABounds(PathATPA[i]);
SetColorSpeed2Modifiers(0.20, 3.85);
if FindColorsSpiralTolerance(MSX1, MSY1, WallTPA, 12118515, PathBox.X1, Pathbox.Y1, Pathbox.X2, Pathbox.Y2, 10) then
Break;
if i = high(PathATPA) then
begin
writeln('Couldnt find wall color');
Terminatescript;
end;
end;
SetColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
marktime(counter);
while (not isuptext('wall')) do
begin
r := random(length(WallTPA));
mmouse(WallTPA[r].x, WallTPA[r].y, 2, 2);
wait(randomrange(200, 500));
if timefrommark(counter) > 10000 then
begin
writeln('couldnt find it');
Logout;
Terminatescript;
end;
end;
ClickMouse2(Mouse_left);
end;
while (isMoving) do
wait(50);
while (AveragePixelShift(PBox, 250, 500) > 300) do
wait(150);
end;