SRL Archive - SRL Suggestions

UpTextGone


NKN

2012-04-22 19:19:05

Once again I was looking for something in SRL, and it wasn't there. D:
I needed to wait for the Uptext to be gone, before moving on. It's useful in say, cleaning herbs, or eating food. It used WaitUpTextMulti, and just changed it around a bit.


function UpTextGone(S: TStringArray; Time: Integer): Boolean;
var
T,i: Integer;
There:Boolean;
begin
Result := false;
T := GetSystemTime + Time;
while (GetSystemTime < T) do
begin
if(i = 0) then
begin
if (IsUpTextMultiCustom(S)) then
begin
There := True;
Inc(i);
end;
end;
if(There = True) then
begin
i := 0
if not(IsUpTextMultiCustom(S)) then
begin
Writeln('Uptext gone');
There := False
Result := True;
Exit;
end;
end;
end;
Wait(20 + Random(20));
end;

Thoughts?

Sex

2012-04-22 19:22:04

No. We don't need all these small functions.

Use WaitFunction.

Nebula

2012-04-22 19:23:00

Or you could just do


begin
Marktime(t);
result := False;
while (Marktime(t)<Time) do
begin
if not IsUpTextMultiCustom(S) then
begin
result := true;
break;
end;
end;
end;

Excuse me if that isn't properly formatted, I haven't done any scripting in a while.

NKN

2012-04-22 19:23:20

How would WaitFunction work here? o.O

Sex

2012-04-22 19:40:30

From: NKN
How would WaitFunction work here? o.O



var
v : TVariantArray;
[...]
v := ['a', 'b', 'c'];
if not WaitFuncEx('IsUpTextMultiCustom', v, 20, 1000) then
exit; // blah
Some shit like that.

Nebula

2012-04-22 19:42:14

From: Sex

v := ['a', 'b', 'c'];
if not WaitFuncEx('IsUpTextMultiCustom', v, 20, 1000) then
exit; // blah


That would wait a full second no matter what. He wants it to wait until IsUpTextCustom = false.

Sex

2012-04-22 19:48:32

Right, then you can write a wrapper and use WaitFunc.

var
s : TStringArray;
[...]
function IsUpTextMultiCustomWrap : boolean;
begin
result := not IsUpTextMultiCustomWrap(s);
end;

WaitFunc(@IsUpTextMultiCustomWrap, 200, 100);
My point is just that there is no reason for this to be in the include..