SRL Archive - Outdated Tutorials

InterScarMessage


Avaphi

2007-03-11 23:20:28

~InterScarMessage~
What is it and How to use it to your advantage



~What Is It?~
InterScarMessage. It is a way to setup two instances of SCAR, and have them communicate with each other. To understand better we must look at the two functions provided for us by Kaitnieks.

SendInterSCARMessage(id, message: string);

Description: The name of the procedure is named perfectly as to what the procedure itself does. It Sends a message from one instance of SCAR to another.(Receiving that message is the job of another procedure) Now to actually get the communication to happen you must edit the arguments of the procedure, lets take a look at them now.

Id: This is basically a way of telling SCAR the name of the "Channel" that you wish to send the message on. It does *NOT* matter what you name this, but as to normal variables in programming, It definetly helps if you give it some meaning. In our example we will simply call it Channel. Make sure it is a string !

Message: What this is, is what message you wish to send on the specified "Channel" you have chosen earlier. Again, this arguments name doesn't really matter, although you should give it some meaning. Make sure it is a string !

ReadInterSCARMessage(id: string): string

Description: The name of the procedure is named perfectly as to what the procedure itself does. It reads a message that was sent from another instance of SCAR by means of SendInterSCARMessage. Now to actually get receive the messages that were sent you must edit the arguments of the procedure, lets take a look at them now.

Id: What the Id argument is for, is just making sure that your SendInterSCARMessage and ReadInterSCARMessage are on the same channel. Pretty much the only thing you need to worry about is making it the exact same as how it is in the ReadInterScarMessage. Make sure it is a string !

Message: Similar to Id, you must make sure theat your SendInterSCARMessage "Message" and your ReadInterSCARMessage "Message" are both exactly the same. Make sure it is a string !

Now that you have a pretty good understanding of the Main Procedures/Functions, it is time to learn how to use them in a way that will aid your script(s).

~Using it~

To see an example of how to use ISM, Take a look at the two scripts at the bottom of this post. Make sure both windows have the cross hairs dragged onto the client then run ISM2, then ISM1.(PS: If you want them to actually work, try putting the mining procedure in a loop and give it some color & tolerance + fill in the main loop for ISM1)

ISM1:

program ISMTutorial1;
{.include SRL/SRL.scar}

Function ISMFindRandoms: boolean;
begin
SendInterSCARMessage('Control', 'Randoms');
Wait(1000);
if (ReadInterSCARMessage('Control', 'Handlers') then
begin
Result := True;
FindNormalRandoms;
end;
end;

Procedure Mine;
begin
if(FindObj(x, y, 'Mine', Color, Tolerance)) then
begin
Mouse(x, y, 0, 0, True);
end;
end;

begin
end.

ISM2:

program ISMTutorial2;
{.include SRL/SRL.scar}

Procedure ISMFindRandoms;
begin
Repeat
if (ReadInterSCARMessage('Control', 'Randoms')) then
begin
writeln('SCAR Instance is requesting Random Handlers... Accesing...');
SendInterSCARMessage('Control', 'Handlers');
end;
Until(False);
end;

begin
SetupSRL;
ISMFindRandoms;
end.

Thick As Blood

2007-03-12 00:13:21

this is going to come in handy when the new version of SCAR comes out eh? i'm sure their will be a way to correspond with the tabbed windows :)