Channel
The
chat and
listen functions use a "channel" system to send messages back and forth. Any script can intercept these messages if it knows the channel to listen on. There are 4,294,967,294 possible channels, represented as an
integer in the range of (-2,147,483,648) to 2,147,483,647. Channel 0 is the only one sent to
agents--only messages on it appear in the chat window. All other channels are for
scripts only.
Chat channels are not to be confused with
XML-RPC data channels.
When typing in the chat window, you can specify the channel with /<channel number>, as in:
/42 This goes to channel 42, but won't be heard by nearby agents
Chat can only be generated by agents on negative channel numbers through
llDialog. This means that typing
"/-13 Whatever" into your chat bar won't work.
This gets a channel from the name of the
owner:
(If there's no other way for multiple objects to communicate, it's also not very secure):
list letters = [" ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
integer ChannelFromName()
{
integer x;
integer length;
integer channel;
string owner = llToLower(llKey2Name(llGetOwner()));
for(x=0, length=llStringLength(owner); x<length; ++x)
{
channel+=llListFindList(letters,[llGetSubString(owner,x,x)]);
}
return channel;
}
This will generate a random (positive or negative) channel number.
integer DlgChannel = 0;
{
do
{
DlgChannel = ((integer) llFrand(3) - 1) * ((integer) llFrand(2147483647));
}
while(DlgChannel == 0);
}
Uses full range of available channels, excepting channels 0, 2147483647 (DEBUG_CHANNEL), -2147483647 and 2147483648. -
DavidSoon
Channel Functions
llDialog
llListen
llListenControl
llListenRemove
llSay
llShout
llWhisper
Channel Events
listen
Constants
Communications |
Chat