SRL Archive - Outdated Tutorials

InterSCARMessages


Da 0wner

2009-05-29 10:05:49

Haider, this is going to be a super short and to the point tutorial. These are pretty easy so that is why it is in the beginners section.

InterSCARMessages are basically messages that can be read and sent throughout every SCAR on the same computer. They are sent over different "channels". Each channel can hold a different message.

There are a few functions you should know about.

SendInterSCARMessage(ID, Message : string) : boolean;

This function sends the message over the channel ID. There are also different ones like SendInterSCARBoolean (etc.) and those are pretty straight forward.

ReadInterSCARMessage(ID : string) : string;

This function reads the message residing in the channel ID. It returns the string.

Now that is basically really all that you need to know.

But one thing, after you read the message, you should send a message back to the same channel that is blank so that it does not read it again.

Please post, PM me, or add me on MSN (kylewollaston@hotmail.com) if you need help.

You can also look in AppPath + 'Scripts\Test\InterSCARMessageTest.scar', AppPath + 'Scripts\Test\Command_Plane.scar' and AppPath + 'Scripts\Test\Command_Tower.scar'.

Those are some examples. I decided to write this because of http://www.villavu.com/forum/showthread.php?t=45800. One example is what I posted there (my third post).

cycrosism

2009-05-29 10:41:56

Looks very nice :)

Awkwardsaw

2009-06-30 00:20:41

so, what would this be used for? like, if you where running multiple scripts at a time, and you use sendinterscar to give them(or specific) code, which can be translated to a command? like


if (ReadInterSCARMessage('lol') = 'Stop') then terminatescript;

ian.

2009-06-30 00:44:02

Yes, you could do that, akwardsaw. You could also just have something running on the script that's autoing like if(IsFKeyDown(2))then blahblahblah; You know? (Open up a Readln, then TypeSend that).

Da 0wner

2009-06-30 02:49:12

Yes, but make sure you clear the channel after doing the command.

Nadeem

2009-07-03 23:07:07

Nice tut :) Rep++!

You should throw in a sample code though, with how to clear the channels.



~NS

Da 0wner

2009-07-13 11:53:18

SendInterSCARMessage(CHANNEL, '');
:D

Edit: Wtf, who moved this to super advanced -_-.

mixster

2009-07-13 12:03:18

I usually prefer to send a boolean through ISM to say whether or not to run a command. I like it since it makes it more structured as it's much easier to do "if ReadBool then" than "if ReadMess <> '' then". Doesn't really do much more apart from that, but I like it that way :)

ShowerThoughts

2009-07-13 12:05:24

For example you could have a repeat loop on receiving some message from a server(Stop Signal) then you can use this, and then terminate script in the main script! Not like RC that you have to wait 5 mins…

Smartzkid

2009-07-21 06:08:54

From: Da 0wner
Edit: Wtf, who moved this to super advanced -_-.


Ditto.

Da 0wner

2009-07-21 06:24:31

I asked Chris and he said Zeph moved it to advanced, then RM moved it here.

Smartzkid

2009-07-22 03:20:28

RM, WHY? *dies*

jnewman

2009-08-25 21:34:24

When invoking the command "SendInterSCARMessage" can someone tell me how to make the dialog box pop up in front of the smart window? It always appears behind my open windows.

I'm thinking of something like 'ShowModal' or do I have to create a form for input? I'm new to SCAR coding but am enjoying it.

Naum

2009-08-25 22:19:23

From: jnewman
When invoking the command "SendInterSCARMessage" can someone tell me how to make the dialog box pop up in front of the smart window? It always appears behind my open windows.

I'm thinking of something like 'ShowModal' or do I have to create a form for input? I'm new to SCAR coding but am enjoying it.


Hi there, you need to do: GetApplication.BringToFront;, before you call the pop-up to appear :).

jnewman

2009-08-25 22:25:23

Thank you kindly, I'll give it a crack :-)

Xtensity

2010-06-03 11:21:10

I know this is a year old topic, but I figured out something that may make it easier for others to understand. It makes it easier for me to understand at least.

The ScarInterMessages can be treated as "Global Variables", in a sense that, the channel name would be the variable and the other part of it would be the value of the variable.

That's the concept I understand it to be… I figure it would be more effective be simply be able to estable global variables at the top of the script where you establish your normal vars. With these scarintermessages you can send strings, numbers, and booleans, but they all need to be converted to a string to be sent/'stored'.

If a "Global Variable" feature was implemented then we could do things like have global TPAs etc.

It's one thing for scripts to send messages, but imagine if we could make 2 scripts co-operate and use Global TPAs. I'm not aware of any actual uses other then pure scripting fun, but I know various uses would show them selfs as time progresses.