SRL Archive - Outdated Tutorials

New Scar function getstatus


jhildy

2007-06-06 21:33:05

I havn't seen any scripts use this. I myself started to use it recently because it is helpful.

Using Status and Getstatus

well a new function was put into scar and i took advantage of it and used it as basically a hidden variable.

Status

For people who dont know, there is a procedure"Status(s: string);"
In scar Status is used to change a text at the bottom. The program uses it quite frequently. Status is the text that says "Script running" or "Script terminated" near the bottom.

Get Status
You can change this using the procedure i mentioned earlier.
in the new verison of scar though, there was GetStatus: string; function.
this would return the value of Status as a string. This allows you to use this as an undeclared varaible(meaning you dont have to declare it in your script).
In some peoples scripts they used Players.loc = 'bank'; or a similar variable. I found using GetStatus to work just as well. it also could be a failsafe to make sure the script gets to the next part.


Below is an example of how it would be used.
program New;
{.include SRL/SRL.scar}
procedure FindBanks;
var x,y,i: integer;
begin
i:=0;
repeat
if (findsymbol('bank',x,y)=true) then
begin
Mouse(x,y,3,3,true);
Status('walking to bank');
flag;
end else;
i:=i+1;
until(getstatus='walking to bank') or (i>=10);
end;

begin
setupSRL;
repeat
findbanks;
if getstatus = 'walking to bank' then
writeln('walking to bank!');
else writeln('not walking to bank');
until(false);
end.

this wont compile for me but it is not meant to work it's just an example of how to use it.

Therefore this function could be used as another failsafe.

Smartzkid

2007-06-06 21:36:46

Interesting idea, but it doesn't sound too safe…

What if someone pauses the script in the middle, or SRL puts something in the status bar, etc…?

jhildy

2007-06-06 21:40:14

well its just another easy failsafe to include.

not saying it should be the only one but it could help.
and you could check if Getstatus='whatever' before the whole procedure is started and if its not then make it that.

Smartzkid

2007-06-06 21:44:59

But….why not just use a variable?

jhildy

2007-06-06 21:46:12

idk y use a variable?

Smartzkid

2007-06-06 21:48:40

Why not?

More reliable

More efficient

etc

Though I guess this would work….I just don't see any advantages it has

jhildy

2007-06-06 21:50:21

well its just something i noticed that i thought i would point out. it may have use to some people.

Dan Cardin

2007-06-07 14:52:52

hmmm..nice observation…but i would definately not make it be my only failsafe…just as an extra precaution

Smartzkid

2007-06-07 15:23:12

I think this 'getStatus' function could be pretty sweet for making statusbar animations

Don't know anything else, though…. :redface: