SRL Archive - OSR Intermediate Scripting Tutorials

The correct way to find randoms


Cazax

2009-02-04 15:00:31

I have seen scripts are calling randoms in a wrong way:
Procedure CheckRandoms;
Begin
FindNormalRandoms;
End;

That's wrong, if you get an unsolvable random or it couldn't solve a random, FindNormalRandoms will logout. So, if you call it inside a loop for example:
Repeat
CheckRandoms;
If FindTree(X, Y) Then
Begin
Mouse(X, Y, 5, 5, True);
..................
It would logout and start searching for a tree. How to call it:
Repeat
If FindNormalRandoms Then
If Not LoggedIn Then
Exit;
If FindTree(X, Y) Then
Begin
Mouse(X, Y, 5, 5, True);
..............
That's why FindNormalRandoms is a function, not a procedure. You could adapt it to check fights too. example:
Function Randoms: Boolean;
Begin
Result := FindNormalRandoms;
If FindFight Then
Begin
...
Result := True;
End;
End;

......

If Randoms Then
Begin
Writeln('Found random/fighting random!');
If Not LoggedIn Then
Exit;
End;
Thank you for reading :)

From: tarajunky
Just be sure you don't do this in your main loop, or it will accidentally terminate your script. Sometimes instead of exit; you need to use break;

Heavenzeyez1

2009-02-04 15:11:52

That's why my woodcutter always keeps looking for the tree in Molly etc…
Thanks a ton!
~Eerik~

noidea

2009-02-04 15:29:58

I didnt relise this eigther! Its amazing on how people get to SRL members, and not know this. Rep'd.

Heavenzeyez1

2009-02-04 15:38:11

From: noidea
I didnt relise this eigther! Its amazing on how people get to SRL members, and not know this. Rep'd.


Exactly. Like.. when I first didn't have any antirandoms.. people used to say: "Just add FindNormalRandoms; to somewhere. -.- , so I thought that was it. But later one day, I thought why it will search for tree in molly, I was like. :|
Forgot to mention, rep'd. :)
~Eerik~

tarajunky

2009-02-04 16:03:43

Just be sure you don't do this in your main loop, or it will accidentally terminate your script. Sometimes instead of exit; you need to use break;

Coh3n

2011-02-14 14:14:01

Hm, I always knew it was a function, but never realized it logged out. Explains a lot…

Guess you learn something new every day. ;)

E: I actually went through Reflection's and SRL's FindRandoms, and neither return true if they failed. They only return true when the random is solved. Please, correct me if I'm wrong.