Table of Contents

ChangeLog

31 December 2011

  • Some observations from Willy Sandalwood:
    • The object that contains the script has to be deeded to the group that owns the land, if the land is group owned.
    • 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.

Introduction

This script was tested and works on OpenSim version 0.7.4!

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.

Setup

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:

Morgan LeFay#cb2b66d7-4ca3-6f5e-a126-3108d4a634e9

The first field before the hash represents the Dj's username, in this case Morgan LeFay 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 = "http://www.google.com";
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 Morgan LeFay every 30 seconds in a range of 10 meters. If it does not find the DJ Morgan LeFay, 10 times one after the other, it will set the parcel music URL to "http://www.google.com".

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

Code

streamtimeout.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, 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 = "http://www.google.com";
// 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;
    }
    return;
@found_djlist;
    dLine = 0;
    dQuery = llGetNotecardLine("DJ List", dLine);
}
 
default
{
    state_entry() {
        init();
    }
 
    on_rez(integer num) {
        init();
    }
 
    changed(integer change) {
        if(change & CHANGED_INVENTORY)
            llResetScript();
    }
 
    timer() {
        if(!dLine) {
            llSetTimerEvent(.0);
            llSetParcelMusicURL(RADIO_URL);
            return;
        }
        llSetTimerEvent(30);
    }
 
    sensor (integer num) {
        integer itra;
        for(itra=0; itra<num; ++itra) {
            if(~llListFindList(dList, (list)llDetectedKey(itra))) {
                dLine = ALLOWED_SCAN_FAILS;
                llSetTimerEvent(30);
                return;
            }
        }
        if(dLine > 0) {
            --dLine;
        }
    }
 
    dataserver(key query_id, string data) {
        if(query_id == dQuery) {
            if(data == EOF) {
                dLine = ALLOWED_SCAN_FAILS;
                llSetTimerEvent(30);
                llSensorRepeat("", "", AGENT, SCAN_RANGE, TWO_PI, SCAN_INTERVAL);
                return;
            }
            if(data == "") jump next_line;
            list pData = llParseString2List(data, ["#"], [""]);
            if(llKey2Name(llList2Key(pData, 1)) == llList2String(pData, 0))
                dList += llList2Key(pData, 1);
@next_line;
            dQuery = llGetNotecardLine("DJ List", ++dLine);
        }
    }
}

secondlife/stream_timeout.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.