SRL Archive - SRL Suggestions

Useful Functions


Sin

2012-04-24 10:29:03

function WaitInvCountChange(Time:Integer):Boolean;
var
Inv1,Inv2,t:Integer;
begin
MarkTime(t);
Inv1 := InvCount;
repeat
wait(10);
Inv2 := InvCount;
if TimeFromMark(t) > Time then
begin
Result := False;
Exit;
end;
until(Inv2 <> Inv1);
Result := True;
end;

function WaitNPCChatText(Text:String; Time:Integer; Action:Variant):Boolean;
var
t:Integer;
begin
MarkTime(t);
repeat
wait(10);
if TimeFromMark(t) > Time then
begin
Result := False;
Exit;
end;
until(FindNPCChatText(Text,Action));
Result := True;
end;

function WaitXPIncrease(Time:Integer):Boolean;
var
First,Second,t:Integer;
begin
First := GetXPBarTotal;
MarkTime(T);
repeat
wait(10);
Second := GetXPBarTotal;
if TimeFromMark(t) > Time then
begin
Result := False;
Exit;
end;
until(Second > First);
Result := True;
end;

Brandon

2012-04-24 10:38:13

Why have an increase and decrease one when you can make one that does both? As long as the invcount changed then it works for removing and adding.


Function WaitInvChanged(TimeToWait: Integer): Boolean;
Var
T, InitCount: Integer;
begin
InitCount:= InvCount;
Result := False;
T := GetSystemTime + TimeToWait;
while (GetSystemTime < T) do
begin
if (InvCount <> InitCount) then
begin
Result := True;
Exit;
end;
Wait(20 + Random(10));
end;
end;

Sin

2012-04-24 10:39:19

Ah, couldn't remember the sign haha.
Edited, thanks!

putonajonny

2012-04-24 11:07:07

Another useful one would be waiting for it to change to a specific amount, e.g.
function WaitInvCount(InventCount, Time : Integer) : Boolean;
var
Inv, t : Integer;
begin
MarkTime(t);
Inv := InvCount;
Repeat
wait(10+Random(10));
if(Inv <> InvCount)then
begin
MarkTime(t);
Inv := InvCount;
end;
if TimeFromMark(t) > Time then
begin
Result := False;
Exit;
end;
Until(InventCount = InvCount);
Result := True;
end;

Sin

2012-05-10 07:23:50

Push?

Sirenia

2012-05-10 08:13:21

I like the WaitNPCChat one. Now can Invalids and mine kebab buyer be much more efficient :)