A constant problem in LSL is the constant use of the same channel for everything
in scripts. This causes a fair deal of unnecessary lag
, and leads to many a server instability.
Ever wish you could create an arbitrary channel
that can be discovered by any script? You can!
The secret is converting a key
into a channel
in a predictable way. One tried and true method is to use the hex
integer Key2Channel(key given, integer num_digits)
// Creates a private channel using a known key value given and num_digits
// Interestingly, you can find this number in any object by using a sensor
string known = (string)given;
integer count = llStringLength(known) - 1;
string channel = ""; // String for channel creation
for(i = 0; i < count; i += 2)
channel += (string)((integer)("0x" + llGetSubString(known,i,i + 1)));
if(llStringLength(channel) >= num_digits)
i = count;
// Return the value
integer Key2Integer(string input, integer start, integer chars)
start, start + chars - 1));
This trick also works with a script pin
for even more script-fu.