SRL Archive - OSR Help

Failsafe timer


Rally

2012-01-21 04:01:11

Hello, im trying to make a failsafe timer for checking if inventory count has changed.

Thought of someting like this:
procedure Test;
var
Count, Timer: Integer;
begin
MarkTime(Timer);
repeat
Count:= InvCount;
until (TimeFromMark(Timer) >= 10000)); // here i need the loop to break if Count is still the same after 10 seconds.
end;

How should i write the until statement?

Inception

2012-01-21 04:50:59

Here is what you asked for (plus a little), but you shouldn't rely on this method alone. For example, if this is a woodcutting script, your character will stand around for 10 seconds after a tree is chopped down before it attempts to find another.

procedure Test;
var
prevCount, curCount, Timer: Integer;
begin
MarkTime(Timer);
prevCount := InvCount;
repeat
if InvFull then
Exit;

curCount := InvCount;
if not curCount = prevCount then
begin
MarkTime(Timer);
prevCount := curCount;
end;
until (TimeFromMark(Timer) >= 10000)) and (prevCount = curCount);

if prevCount = curCount then
begin
writeln('The inventory count has not changed in the last 10 seconds.');
Exit;
end;
end;

If it was me, I would do something like this:

procedure Test;
var
prevCount, curCount, Timer: Integer;
begin
MarkTime(Timer);
prevCount := InvCount;
repeat
if not LoggedIn then
Exit;

curCount := InvCount;
if not curCount = prevCount then
begin
MarkTime(Timer);
prevCount := curCount;
end;

if (TimeFromMark(Timer) >= 10000)) and (prevCount = curCount) then
begin
writeln('Idle character.');
Exit;
end;

// More tests

until InvFull;
end;

Rally

2012-01-21 06:21:52

Thanks for your reply. This is exactly what i needed

And no i wont have this failsafe only. But i needed it to fix if Pixelshift fails, for example if there is a tree overlapping the view. Btw it's a fishing script.

But thanks again for your help :)