Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Channel relay agent

ZHugh Becquerel
Registered User
Join date: 24 Oct 2003
Posts: 68
10-30-2003 07:06
Debugging inter-object shout communication can be tricky. An object containing the following code can help here. It will eavesdrop on your secret channel, and allow you to broadcast anything you want, in-channel.

You set your channel number in Channel at the top, then start the script.

Anything that the object hears on the Channel will be repeated back to you in channel 0.

You can get it to say stuff in-channel by using the channel 0 command "relay-=-" + whatever you want to say in-channel.

If it gets too noisy, just say "echo_off" to shut it up. "echo_on" turns it back on.

ZHugh


CODE

integer MessagesOn = TRUE;
integer Channel = 1234; // Set your channel number here

integer g_listener=-1;

TellOwner( string message )
{
// llInstantMessage( llGetOwner(), "InChannel:" + Message );
llWhisper( 0, message );
}

SayInChannel( string Message )
{
llShout( Channel, Message );
TellOwner( "InChannel:" + Message );
}

DoMonitoring(integer channel, string name, key id, string message)
{
list Arguments;
Arguments = llParseString2List( message, ["-=-"], [] );
string Command;
Command = llList2String( Arguments, 0 );
if( channel == Channel )
{
if( MessagesOn )
{
//llInstantMessage(llGetOwner(),name + " - " + (string)id + " - " + message);
TellOwner( name + ": " +message );
}
}
else if( channel == 0 )
{
if( message == "echo_off" )
{
MessagesOn = FALSE;
llSay(0,message);
}
else if( message == "echo_on" )
{
MessagesOn = TRUE;
llSay(0,message);
}
else if( Command == "relay" )
{
string MessageToRelay;
MessageToRelay = llGetSubString( message, 8,1000);
SayInChannel( MessageToRelay );
}
}
}

AddChannelListener()
{
if( g_listener == -1 )
{
g_listener = llListen(Channel,"","","");
}
else
{
llSay(0, "failed to add listener!");
}
}

RemoveListeners()
{
if( g_listener != -1 )
{
llListenRemove( g_listener );
g_listener = -1;
}
}

default
{
state_entry()
{
AddChannelListener();
llListen(0,"",llGetOwner(),"");
}
listen(integer channel, string name, key id, string message )
{
DoMonitoring(channel, name, id, message);
}
}
Jack Skallagrimson
バナナの電話!
Join date: 17 Jul 2003
Posts: 63
11-01-2003 18:26
hmmm... so it is like a radio? different frenquencys? or does it IM the owner on what other people in its range are saying? if it is a radio, it would be VERY usefull...
_____________________
hi
ZHugh Becquerel
Registered User
Join date: 24 Oct 2003
Posts: 68
11-03-2003 14:12
Errr it's like a radio, for inter-object communication. Of course you have to know the channel number, and there's over two million possibilities, so it's strictly for debugging purposes for one's own projects. It would be fairly challenging to scan for unknown channels.

By the way theres a new version now, which will replace $MYID$ with the owners key id. Available in-game.

ZHugh
Mark Michelson
Particle Man
Join date: 22 Jul 2003
Posts: 93
11-04-2003 14:44
I have an object similar to this that I've used a lot for debugging. I can just ask it monitor a given channel number and it relays any activity on that channel. Very handy, and I'm not sure why I never made mine relay my speech on the non-zero channel. Good idea.

Like ZHugh said, you have to know the channel number anyway so it's not useful to 'eavesdrop' on other people's objects.