SRL Archive - OSR Beginner Scripting Tutorials

How to use SRL's Random Tool in a script


Coh3n

2012-03-13 02:33:02

SRL's Random Tool
____________________________


[BANANA][/BANANA]



What is SRL's Random Tool?
[INDENT]It's a pretty neat tool. It notifies (optionally plays a sound) the user when SRL has detected a random event, and gives them the option to have SRL solve the random, or solve it manually.

SRL's Random Tool source code can be found here, or in SRL/SRL/core/antirandoms/randomtool.simba.
[/INDENT]


How to add SRL's Random Tool to a script:[INDENT]Very, very simple. Just call SetupRandomTool(timeOutWait, FKeyFinish: integer; soundPath: string); sometime after SetupSRL() and DeclarePlayers().
  • timeOutWait: How long to wait (in milliseconds) before closing the Random Tool form and having SRL solve the random.
  • FKeyFinish: The F key that is pressed when the user has finished manually solving the random.
  • soundPath: The path to the sound file to be played when a random event is detected.
For example,

setupRandomTool(10000, 5, 'C:/Simba/randomSound.wav');
[/INDENT]


Additional options:[INDENT]Since not all users will want to take advantage of this feature, I recommend giving them the option. Using a simple constant or variable boolean statement will work nicely.

Example (just copy/paste into Simba if you want to test):

program test_RandomTool;
{$i srl\srl.simba}

procedure declarePlayers;
begin
howManyPlayers := 1;
numberOfPlayers(howManyPlayers);
currentPlayer := 0;

with players[0] do
begin
name := 'Coh3n';
pass := 'myPassword1234';
active := true;
end;
end;

begin
clearDebug();
activateClient();

setupSRL();
declarePlayers();
setupRandomTool(25000, 5, '');

RT_Execute();
end.
[/INDENT]


Conclusion:
[INDENT]If you have any questions, suggestions, or comments, please post here.

Cheers,
Coh3n
[/INDENT]

NCDS

2012-03-13 21:35:36

Ah good idea! Should prove to be a very useful tut. :)

Ashaman88

2012-03-13 21:51:57

This is very handy, thanks!

punkd

2012-03-21 15:13:40

Ahah, what a 'Cute' tool =P love it!

zamserv

2012-03-21 15:35:31

love it! what randoms will it be able to solve?

Coh3n

2012-03-22 00:42:00

It's not the tool that solves the randoms, it's SRL. The status of each solver can be found here.

zamserv

2012-03-22 09:06:38

i added to script, and it compiled and worked good, but i didnt see any popup like on the picture that ask me how i want to solve random. this is where it is:


begin
Smart_Members := False;
Smart_Server := 0;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
DeclarePlayers;
LoginPlayer;
setupRandomTool(25000, 5, '');

alexes

2012-03-22 09:13:49

:O Really useful, added it in the script im running atm and it works perfectly! I love it. Thank you very much Coh3n for this ^^

Coh3n

2012-03-22 11:41:04

From: zamserv
i added to script, and it compiled and worked good, but i didnt see any popup like on the picture that ask me how i want to solve random. this is where it is:


begin
Smart_Members := False;
Smart_Server := 0;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
DeclarePlayers;
LoginPlayer;
setupRandomTool(25000, 5, '');
You still have to call FindNormalRandoms, otherwise it doesn't know when to pop up.

brit ftw

2012-03-28 01:43:11

i find it dificult ^^

Aegis

2012-03-30 02:00:27

Woah, awesome! I'll surely implement this in my future scripts. Thanks.

Abu

2012-03-30 02:20:33

From: brit ftw
i find it dificult ^^


To do what exactly? FindNormalRandoms?

You simply write it in at the start of a function….

injustice

2012-03-30 10:13:01

Great idea! I'll try and add this to my upcoming script :)

fJX

2012-04-01 08:34:28

This is really nice..Using it right now in a script I just wrote, works beautifully and pops up to tell me, which is quite nice when running multiple scripts.. :D

Any plans to further the notification system? I'd really love to see this be able to send an email to a specified address.

Coh3n

2012-04-01 22:46:52

From: fJX
This is really nice..Using it right now in a script I just wrote, works beautifully and pops up to tell me, which is quite nice when running multiple scripts.. :D

Any plans to further the notification system? I'd really love to see this be able to send an email to a specified address.
If Simba ever gets a SendEmail method, I'd be happy to add it to this tool, but until then, don't count on it. :p

Shatterhand

2012-04-02 05:18:27

Pretty nice, this what I was looking for! :)

Abu

2012-04-09 09:37:27

From: fJX

Any plans to further the notification system? I'd really love to see this be able to send an email to a specified address.


Why on earth would you want that? :confused:

OT: Looks very nice, will definitely be using :)

shstiger2009

2012-04-28 16:08:39

From: abu_jwka
Why on earth would you want that? :confused:

OT: Looks very nice, will definitely be using :)


What do you mean? So you would know if you got a random if you weren't babysitting your script. That's why.

Le Jingle

2012-04-28 16:26:32

Does it use the random sound from Simba\Includes\MSI\MSI\RandomSound.wav ?

or should I copy that (& potentially rename) and place it into an appropriate file?


Edit: nevermind, just saw OP:
setupRandomTool(10000, 5, 'C:/Simba/randomSound.wav');

Edit 2: Do I need to worry about RT_Execute(); as shown in your OP mainloop?

bots420

2012-05-02 13:00:54

Thanks for posting :)

Abu

2012-05-04 14:46:37

Ok so basically this found a random and I decided to solve it myself.

Went back to the script to see what 'f' key I had entered to resume scripting - I put 5.

However, after pressing f5 multiple times, my script would not resume.

litoris

2012-05-05 14:49:08

From: abu_jwka
Ok so basically this found a random and I decided to solve it myself.

Went back to the script to see what 'f' key I had entered to resume scripting - I put 5.

However, after pressing f5 multiple times, my script would not resume.


The exact same thing happened to me just now. Had to restart script.

litoris

2012-05-11 10:18:48

From: litoris
The exact same thing happened to me just now. Had to restart script.


Happened again today. Any way to actually make the script resume?

lays

2012-05-23 17:01:37

yea got the same problem script didnt start and solve random with the exp book was spamming the cmd …


is there a simple to code that just plays a sound on random without the tool ?

Abu

2012-05-23 17:26:37

From: lays
yea got the same problem script didnt start and solve random with the exp book was spamming the cmd …


is there a simple to code that just plays a sound on random without the tool ?


You can do that yourself:
if FindNormalRandoms then
PlaySound('file path for sound');

shstiger2009

2012-05-24 00:49:30

From: lays
yea got the same problem script didnt start and solve random with the exp book was spamming the cmd …


is there a simple to code that just plays a sound on random without the tool ?


As abu said, you can do that already.

But it would really be nice if the script resumed when we hit the correct F key!

lured yah

2012-06-16 02:13:29

new Idea: would it be possible to expand this RandomTool to also send an email using the computers' SMTP/Telnet?

Rodelol

2013-04-08 14:27:05

Does this work with OSR?