Difference between revisions of "Chat Relay"

From Second Life Wiki
Jump to navigation Jump to search
 
m (<lsl> tag to <source>)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{LSL Header}}
{{LSL Header|ml=*}}
[[LSL_Examples|Back to Example page]]
[[LSL Library|Back to Library page]]


llShout is limited to 100m and sometimes you need to send a message farther.
llShout is limited to 100m and sometimes you need to send a message farther.
Line 9: Line 7:
# Place in a prim
# Place in a prim
# Change the channel number.
# Change the channel number.
# place them as needed changing the prim's description to a unique letter or number to set it's node name.
# place them as needed changing the prim's description to a unique letter or number to set its node name.
<br>
<br>
The concept is similar to the "path" part of an email message in that it modifies the
The concept is similar to the "path" part of an email message in that it modifies the
message by adding it's name to the message.
message by adding its name to the message.


When it hears a message it parses it to get the first field. The first field is used for performance reasons. This script currently uses the pipe symbol but you can change the field separator as needed.
When it hears a message it parses it to get the first field. The first field is used for performance reasons. This script currently uses the pipe symbol but you can change the field separator as needed.


It then does a string search of the path field using ",n," where n is it's number or letter.
It then does a string search of the path field using ",n," where n is its number or letter.
The "Path" is started with "," and the repeater adds it's number and reshouts it if it has not heard it before.
The "Path" is started with "," and the repeater adds its number and reshouts it if it has not heard it before.


The message goes like this<br><pre>
The message goes like this<br><pre>
Line 30: Line 28:
<br>
<br>
'''Improvements'''<br>
'''Improvements'''<br>
The script could be improved using a string search instead of llParseString2List since it only adds it's name to the start of the message.
The script could be improved using a string search instead of llParseString2List since it only adds its name to the start of the message.
Currently a message with a length of 255 characters when sent through the relay will be shortened. Because of this it is recommended to send messages with a maximum length of 200 characters to allow for 55 characters of path.


<br>
<br>
'''Chat Relay'''<br><pre>
'''Chat Relay'''<br>
<source lang="lsl2">
//Chat relay
//Chat relay
//Released into the public domain by grumble Loudon
//Released into the public domain by grumble Loudon
Line 80: Line 80:
     //********************************************************************************************8
     //********************************************************************************************8
}//default
}//default
</pre>
</source>


'''See also''' <br>
====See also====
llShout
[[llShout]]


{{#vardefine:sort|Chat Relay}}{{LSLC|Library}}{{LSLC|Examples}}
{{#vardefine:sort|Chat Relay}}{{LSLC|Library}}{{LSLC|Examples}}

Latest revision as of 13:15, 24 January 2015

llShout is limited to 100m and sometimes you need to send a message farther. This script is designed to resend the message without getting stuck in a loop.
To use

  1. Place in a prim
  2. Change the channel number.
  3. place them as needed changing the prim's description to a unique letter or number to set its node name.


The concept is similar to the "path" part of an email message in that it modifies the message by adding its name to the message.

When it hears a message it parses it to get the first field. The first field is used for performance reasons. This script currently uses the pipe symbol but you can change the field separator as needed.

It then does a string search of the path field using ",n," where n is its number or letter. The "Path" is started with "," and the repeater adds its number and reshouts it if it has not heard it before.

The message goes like this

pipe message
,1,pipe message
,2,1,pipe message


Trouble shooting
This script can deal with grids or loops in any direction as long as each one is uniquely named. If multiple relays exist with the same name some messages will get lost.


Improvements
The script could be improved using a string search instead of llParseString2List since it only adds its name to the start of the message. Currently a message with a length of 255 characters when sent through the relay will be shortened. Because of this it is recommended to send messages with a maximum length of 200 characters to allow for 55 characters of path.


Chat Relay

//Chat relay
//Released into the public domain by grumble Loudon
//
// Pipe is the section separator
// commas are used to separate path ID's
//
integer g_Channel = 1234;	//change this to your channel

//********************************************************************************************
default
{
    //********************************************************************************************8
    state_entry()
    {
        
        llListen(g_Channel,"",NULL_KEY,"");        
    }
//********************************************************************************************8
    listen(integer channel, string name, key id, string message)
    {        
	//Path|address|protocol|data
        list mList = llParseStringKeepNulls(message,["|"],[]);       
        string path = llList2String( mList,0); 		//get route path

        list pathList = [];
        if (llStringLength(path) > 0)
        {
		pathList  = llParseString2List(path,[","],[]);
        };
        string MyName = llGetObjectDesc();
        if (llStringLength(MyName) > 0)		//prevent infinite loops if description is blank
	{
	        list MyNameList;
        	MyNameList += MyName;
                
	        if (llListFindList(pathList, MyNameList) == -1){   // Returns -1 if not found

	            string Msg =  MyName + "," + message;   //add me to the path
           
	            llShout(g_Channel,Msg);

	        }; //route path
	};// No description
    } // listen
    //********************************************************************************************8
}//default

See also

llShout