SRL Archive - Reflection Help

GetMe.Animation -> AmBusy


Dabbi

2008-09-19 12:16:06

Hey all, I'm in the process of making my first script, it's going to be an anywhere anything smither.
I'm new to scar and pascal, but have been looking at other peoples scripts (mostly the functions and procedures from srl).
Right now I'm trying to make an "AmBusy" function. my idea was to count how many times GetMe.Animation returns -1 over a period of runs

[PHP]Function AmBusy: integer;
var i, summa: integer;
Begin
for i := 0 to 9 do
begin
wait(300);
summa := summa + GetMe.Animation;
end;
Result := summa;
End;[/PHP]

but.. as you might see if you run this, i get type mismatch.
any idea why? i'm thinking it's because it is a negative number, but can't find anything to solve this.

And here is another method i tried. but that also gives an error (Out of Global Vars range)
[PHP]Function AmBusy: integer;
var i, summa: integer;
Begin
for i := 0 to 9 do
begin
wait(300);
if(GetMe.Animation > 0) then
summa := summa + 1;
end;
Result := summa;
End;[/PHP]

Final?
{******************************************************************************* 
Function Busy: boolean;
By: Dabbi
Description: Returns false if only idle animation is found, true otherwise.
Checks 10 times over a period of 3 seconds.
*******************************************************************************}
Function Busy: boolean;
var i, summa: integer;
Me: TMe;
Begin
Result := false;
for i := 0 to 9 do
begin
wait(200 + random(250));
Me := GetMe;
if(Me.Animation > 0) then
Inc(summa)
else
Result := true;
End;
End;

HyperSecret

2008-09-19 12:35:26


Function AmBusy: integer;
var i, summa: integer;
Me: TMe;
Begin
for i := 0 to 9 do
begin
wait(300);
Me := GetMe;
if(Me.Animation > 0) then
summa := summa + 1;
end;
Result := summa;
End;

Should work. You need to declare GetMe; as a TMe; variable.

Dabbi

2008-09-20 12:08:38

thanks alot, worked like a charm.
[PHP]{*******************************************************************************
Function Busy: boolean;
By: Dabbi
Description: Returns false if only idle animation is found, true otherwise.
Checks 10 times over a period of 3 seconds.
*******************************************************************************}
Function Busy: boolean;
var i, summa: integer;
Me: TMe;
Begin
Result := false;
for i := 0 to 9 do
begin
wait(300);
Me := GetMe;
if(Me.Animation > 0) then
summa := summa + 1;
end;
if(summa > 0) then
Result := true;
End;[/PHP]

n3ss3s

2008-09-20 12:47:49

In the future please use SCAR tags instead of PHP tags :p

Naum

2008-09-20 13:38:56

Here much quicker and easier:

{******************************************************************************* 
Function Busy: boolean;
By: Dabbi
Description: Returns false if only idle animation is found, true otherwise.
Checks 10 times over a period of 3 seconds.
*******************************************************************************}
Function Busy: boolean;
var i, summa: integer;
Me: TMe;
Begin
Result := false;
for i := 0 to 9 do
begin
wait(300);
Me := GetMe;
if(Me.Animation > 0) then
Inc(summa)
else
Result := true;
Exit;
End;

Using Inc is faster aswell as using else statements

Nava2

2008-09-20 14:42:14

Randomness… Add it to the waits. :)

E:
{******************************************************************************* 
Function Busy: boolean;
By: Dabbi
Description: Returns false if only idle animation is found, true otherwise.
Checks 10 times over a period of 3 seconds.
*******************************************************************************}
Function Busy: boolean;
var i, summa: integer;
Me: TMe;
Begin
Result := false;
for i := 0 to 9 do
begin
wait(RandomRange(50, 100));
Me := GetMe;
if(Me.Animation > 0) then
Inc(summa);
end;
Result := Summa > 0;
End;