Live Event Timeout

From Second Life Wiki
Revision as of 13:16, 3 June 2012 by Kira Komarov (Talk | contribs)

Jump to: navigation, search

Created by Kira Komarov.


  • 31 December 2011

Some observations from Willy Sandalwood:

  1. The object that contains the script has to be deeded to the group that owns the land, if the land is group owned.
  2. The notecard should be named DJ List (previously the description said it should be named DJ Timeout).

As a note, all my notecard systems have to contain a blank new line at the end. Thus, after you add the DJ names, and keys, line-by-line, make sure you have at least one blank line after that.


If you own a club and have DJs entertaining people with a live event, it sometimes happens that the DJ leaves or permanently crashes and forgets or is unable to set the parcel music URL back to the radio station you usually have on when there is no live event. This script helps you do that automatically without intervention so you do not need to attend every live event or be asked to set the music back to the radio. The script also supports a notecard based configuration so you can add your DJs and it will automatically stop trying to set the music URL back to the radio station as soon as it detects one of your DJs in range.


The script takes a notecard called "DJ List" (the name is important) which should contain a list of DJs who are able to manipulate the music URL of the land parcel your club is on. Here is what an example notecard looks like with only one DJ:

Kira Komarov#cb2b66d7-4ca3-6f5e-a126-3108d4a634e9

The first field before the hash represents the Dj's username, in this case Kira Komarov and the second field after the has represents the key of that DJ.

To set this system up:

  • Create a notecard called "DJ List" (the name is important) like described above and list DJs line by line with their usernames and keys.
  • Create a primitive, or locate a primitive that is well in range and the closest possible to your DJ as you can (ideally, if the DJs would stand still in a certain spot, it would be best if this script is closest to them).
  • Drop the notecard in the primitive your script will be in.
  • Create a new script, name it as you want and proceed to the configuration section in the script to set it up. Although the script contains the documentation you need, here is a description of all the settable parameters in the CONFIGURATION section:
string RADIO_URL = "";
integer SCAN_INTERVAL = 30;
integer SCAN_RANGE = 10;
integer ALLOWED_SCAN_FAILS = 10;

the RADIO_URL is self-explanatory, it represents the URL of the radio station you have on when there is no live event going on. The SCAN_INTERVAL represents how often (in seconds) the script will attempt to scan for a DJ and check if they are still there. The SCAN_RANGE represents how far (in meters) the script will scan in order to find a DJ. The last setting, ALLOWED_SCAN_FAILS is the number of times the script will not find a DJ after which it will set the parcel music URL to the RADIO_URL: sometimes a DJ may crash or, in very busy clubs, a scan might fail to find a DJ. In that case, it would be annoying to set the music URL to the RADIO_URL right away. Instead, this setting will allow you to relax the scans and make sure that only after a certain number of times that it fails to find a DJ, it should consider that DJ gone and set the music url to the radio station.

In this, given the configuration above, the script will scan for Kira Komarov every 30 seconds in a range of 10 meters. If it does not find the DJ Kira Komarov, 10 times one after the other, it will set the parcel music URL to "".

  • After you have configured the script, drop the script in the same prim where you placed the notecard.


<lsl gremlin="Live Event Timeout"> ////////////////////////////////////////////////////////// // [K] Kira Komarov - 2011, License: GPLv3 // // Please see: // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // //////////////////////////////////////////////////////////

////////////////////////////////////////////////////////// // CONFIGURATION // ////////////////////////////////////////////////////////// // // // Set this to the URL of a radio station to which the // land parcel should switch to once the DJ leaves. string RADIO_URL = ""; // This represents the interval in seconds between scans. integer SCAN_INTERVAL = 30; // This represents the range for the scans. integer SCAN_RANGE = 10; // Whenever a DJ is not found after a scan, the script // will decrement this value. When this value reaches 0, // the script will consider that the DJ has left and // it will switch to the configured radio station. This // is done this way, because sometimes scans fail and // they are unable to locate a DJ. This is some sort of // error fuzz that the script will allow. integer ALLOWED_SCAN_FAILS = 10; // // // END CONFIGURATION // //////////////////////////////////////////////////////////

////////////////////////////////////////////////////////// // INTERNALS // ////////////////////////////////////////////////////////// key dQuery = NULL_KEY; integer dLine = 0; list dList = [];

init() {

   integer itra;
   for(itra=0; itra<llGetInventoryNumber(INVENTORY_NOTECARD); ++itra) {
       if(llGetInventoryName(INVENTORY_NOTECARD, itra) == "DJ List")
           jump found_djlist;


   dLine = 0;
   dQuery = llGetNotecardLine("DJ List", dLine);


default {

   state_entry() {
   on_rez(integer num) {
   changed(integer change) {
       if(change & CHANGED_INVENTORY)
   timer() {
       if(!dLine) {
   sensor (integer num) {
       integer itra;
       for(itra=0; itra<num; ++itra) {
           if(~llListFindList(dList, (list)llDetectedKey(itra))) {
               dLine = ALLOWED_SCAN_FAILS;
       if(dLine > 0) {
   dataserver(key query_id, string data) {
       if(query_id == dQuery) {
           if(data == EOF) {
               dLine = ALLOWED_SCAN_FAILS;
               llSensorRepeat("", "", AGENT, SCAN_RANGE, TWO_PI, SCAN_INTERVAL);
           if(data == "") jump next_line;
           list pData = llParseString2List(data, ["#"], [""]);
           if(llKey2Name(llList2Key(pData, 1)) == llList2String(pData, 0))
               dList += llList2Key(pData, 1);


           dQuery = llGetNotecardLine("DJ List", ++dLine);

} </lsl>