Advertisement
Bugs_Larnia

Key2Channel

May 24th, 2025 (edited)
825
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Key 2 Channel
  2. This script demonstrates how to create a channel from a key. This can be the object key as demonstrated here, or any other key.
  3. Another feature of this script is the use of an application key to made scripts unique to one certain set. By using the bitwise XOR (the ^ operator) we can "salt" the channel with an integer unique to our set of scripts.
  4.  
  5. Another upside of this pattern is that the result will always be a negative channel.
  6. */
  7.  
  8. integer giAppId = 38478;
  9.  
  10. integer GenerateAppChannel()
  11. {
  12.     return (integer)(("0x8" + (string)llGetKey())) ^ giAppId;
  13. }
  14.  
  15. default
  16. {    
  17.     touch_start(integer total_number)
  18.     {
  19.         integer iChannel = GenerateAppChannel();
  20.         llSay(iChannel, "Message on channel " + (string)iChannel);
  21.     }
  22. }
  23.  
Tags: LSL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement