Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sky.FM radio tuner for land Music URL

DangerDave Writer
Registered User
Join date: 3 Mar 2007
Posts: 3
03-18-2007 19:45
This script can be used to "Scan Forward" through a list of Radio Stations to play on your land. It sets the Music URL when touched, and displays the name of the last person who changed the station, along with the time and date.

It also scans the area every 5 seconds for approaching visitors and welcomes them by name.

Here is the script:

CODE

//
// Script for changing the Music link on your land by clicking a sign or other object.
// Written by Second Life resident DangerDave Writer on March 17 and 18, 2007.
// Free to use, modify, and share - enjoy!
//
// Scan full circle around area every 5 seconds for 512 meters out:
//
// How far away do want to scan for approaching avatars?
float scan_meters = 512.0;
// How many seconds inbetween scans?
float scan_seconds = 5.0;
// Peripheral vision: how far to the left and right do we scan?
float Two_PI = 6.283185306;
float scan_radius = Two_PI; // PI times 2 = full circle, PI = half circle.


// Basic text to display above sign:
string sign_text = "Touch me to change the station.";


// Here is the list of channels available (from http://www.sky.fm Internet Radio).
// First line is the URL of the music (or other streaming audio)
// Second line is the description to be displayed on the sign.
// Finally, a blank line to make it easer to read and change.
list channel_list =
[
"http://64.236.98.50:80/stream/1002",
"New Age",

"http://209.247.146.99:8000",
"Oldies",

"http://205.188.215.226:8020",
"Classical & Flamenco Guitar",

"http://160.79.128.61:7724",
"Alternative Rock",

"http://64.236.98.50:80/stream/1006",
"Classical",

"http://160.79.128.61:7694",
"Classic Rap & Hip Hop",

"http://64.236.98.50:80/stream/1019",
"Country",

"http://205.188.215.227:8008",
"Modern Jazz",

"http://205.188.215.228:8006",
"Ambient - a blend of ambient, downtempo, and chillout",

"http://205.188.215.225:8002",
"Breaks - a fine assortment of trance and house breaks",

"http://64.236.98.50:80/stream/1035",
"Chillout - ambient psy chillout",

"http://205.188.215.225:8004",
"Classic Electronica - old school techno, trance & rave",

"http://66.250.45.118:7040",
"DJ Mixes",

"http://207.200.96.229:8030",
"Drum and Bass",

"http://64.236.98.50:80/stream/1024",
"EuroDance",

"http://205.188.215.226:8006",
"Gabber",

"http://64.236.98.51:80/stream/1008",
"Goa & Psychedelic Trance",

"http://64.236.98.50:80/stream/1004",
"Hardcore - DJ mixes, hard dance and NuNRG",

"http://64.236.98.50:80/stream/1025",
"Hard Dance",

"http://64.236.98.50:80/stream/1007",
"House - silky sexy house music",

"http://64.236.98.50:80/stream/1009",
"Lounge - sit back and enjoy the lounge grooves",

"http://64.236.98.50:80/stream/1026",
"Progressive - house, techno, and trance beats for your mind",

"http://209.247.146.98:8000",
"Techno",

"http://64.236.36.54:80/stream/1003",
"European Trance, Techno, Hi-NRG",

"http://64.236.98.50:80/stream/1065",
"Vocal Trance - a fusion of trance, dance, and chilling vocals",

"http:",
"Off",

0 // Mark end of list
];

























////////////////////////////////////////////////////////////////////////////////////////////////////
//
//
// The programming starts here. Do not modify below here unless you know what you are doing.
//
//
////////////////////////////////////////////////////////////////////////////////////////////////////


integer radio_station = 0;
integer num_radio_stations = 0;
string nearby = "";
string music_type = "";
string playing_text = "";
// playing_text = "Now Playing Station " + (string)(1 + radio_station) + " " + music_type;
string current_text = "";
string last_touched_by = "";
string date_selected = "";
string time_selected = "";
list channel_type = [];
list channel_URL = [];

integer init_stations()
{
integer radio_station_max_index = -1;
integer i = 0;
integer entry_type = 0;
string temp_text = "";

channel_type = [];
channel_URL = [];
llSetText("Scanning Stations...", <1,1,1>, 1.0);
// radio_station = (integer)(llFrand(1.0) * 4.0);
for( i = 0; i < llGetListLength( channel_list ); i++ )
{
if ( llGetListEntryType( channel_list, i ) == TYPE_STRING )
{
radio_station_max_index = i;
if( llGetSubString( llList2String( channel_list, i ), 0, 4 ) == "http:" )
{
if ( llStringLength( temp_text ) > 0 )
{
channel_type += temp_text;
}
temp_text = "";
channel_URL += llList2String( channel_list, i );
num_radio_stations++;
}
else
{
if( llStringLength( temp_text ) > 0 )
{
temp_text = temp_text + "\n";
}
temp_text = temp_text + llList2String( channel_list, i );
}
}
}
if ( llStringLength( temp_text ) > 0 )
channel_type += temp_text;
if( radio_station >= num_radio_stations )
radio_station = 0;
if( radio_station < 0 )
radio_station = 0;
music_type = llList2String( channel_type, radio_station );
if( llGetSubString( llList2String( channel_URL, radio_station ), 0, 6 ) == "http://" )
llSetParcelMusicURL( llList2String( channel_URL, radio_station ) );
else
llSetParcelMusicURL( "" );
return num_radio_stations;
}

string set_playing_text()
{
playing_text = "Now Playing Station " + (string)(1 + radio_station) + " " + music_type;
if ( llStringLength( last_touched_by ) > 0 )
playing_text += "\nSelected by " + last_touched_by;
if ( llStringLength (date_selected) > 0 )
playing_text += " on " + date_selected;
if ( llStringLength (time_selected) > 0 )
playing_text += " at " + time_selected;
return playing_text;
}

string now_as_hhmmss()
{
integer t = 0;
integer hours = 0;
integer minutes = 0;
integer seconds = 0;
string time_now = "";

t = (integer)llGetWallclock(); // seconds since midnight

// one hour has 3600 seconds
hours = t / 3600; // get hours (integer division chops off the decimals)

// the modulo operator % gets the remainder of a divison
// in this case, the remaining seconds after removing the full hours
minutes = (t % 3600) / 60; // divide by 60 because we want minutes, chops off decimals again

seconds = t % 60; // get the seconds that didn't fit into full minutes
time_now = "";
if ( hours < 12 )
time_now += "0";
time_now += (string)hours;
time_now += ":";
if ( minutes < 10 )
time_now += "0";
time_now += (string)minutes;
time_now += ":";
if ( seconds < 10 )
time_now += "0";
time_now += (string)seconds;
return time_now;
}

default
{
state_entry()
{
init_stations();
llSetText(sign_text, <1,1,1>, 1.0);
llSensorRepeat( "", NULL_KEY, AGENT, scan_meters, scan_radius, scan_seconds );
}

sensor(integer num_detected)
{
integer i = 0;
string visitors = "visitors";

nearby = "";
for(i = 0; i < num_detected; ++i)
{
if ( i > 0 )
nearby = nearby + ",";
nearby = nearby + " " + llKey2Name(llDetectedKey(i));
}
if ( num_detected == 1 )
visitors = "visitor";
else
visitors = "visitors";
set_playing_text();
current_text = (string)num_detected + " " + visitors + " detected. Welcome" + nearby + "!\n" + sign_text + "\n" + playing_text;
llSetText(current_text, <1,1,1>, 1.0);
}

touch_start(integer num_detected)
{
integer i = 0;
vector avatar_size = <0.0, 0.0, 0.0>;
float meters_tall = 0.0;
integer inches_tall = 0;
integer feet_tall = 0;
integer inches_left = 0;
string feet = "feet";
string inches = "inches";
string height = "";

llSetText( "Stations = " + (string)num_radio_stations, <1,1,1>, 1.0 );
if ( num_radio_stations == 0 )
init_stations();
radio_station = radio_station + 1;
if( radio_station >= num_radio_stations )
radio_station = 0;
music_type = llList2String( channel_type, radio_station );
if( llGetSubString( llList2String( channel_URL, radio_station ), 0, 6 ) == "http://" )
llSetParcelMusicURL( llList2String( channel_URL, radio_station ) );
else
llSetParcelMusicURL( "" );
date_selected = llGetDate();
time_selected = now_as_hhmmss();

// http://205.188.215.226:8020
// http://209.247.146.99:8000
// http://64.236.98.50:80/stream/1002
for(i = 0; i < num_detected; ++i)
{
avatar_size = llGetAgentSize(llDetectedKey(i));
meters_tall = avatar_size.z;
inches_tall = (integer)(0.5 + meters_tall * 39.3700787);
feet_tall = (integer)(inches_tall / 12.0);
inches_left = (integer)(inches_tall - (feet_tall * 12.0));

// llWhisper(0, "Size is " + (string)llGetAgentSize(llDetectedKey(i)));
if( feet_tall == 1)
feet = "foot";
else
feet = "feet";
if ( inches_left == 1 )
inches = "inch";
else
inches = "inches";
height = "";
if ( feet_tall > 0 )
{
height = (string)feet_tall + " " + feet;
if ( inches_left > 0 )
height = height + ", ";
}
if ( inches_left > 0 )
{
height = height + (string)inches_left + " " + inches;
}
last_touched_by = llKey2Name(llDetectedKey(i));
// llEmail( "youremail@yourdomain.com", "Visitor Alert", llKey2Name(llDetectedKey(i)) + " has changed your radio station." );
// llWhisper(0, llKey2Name(llDetectedKey(i)) + ", you are " + height + " tall.");
}
set_playing_text();
current_text = sign_text + " " + playing_text;
llSetText( current_text, <1,1,1>, 1.0);
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
03-21-2007 04:24
/54/4f/172661/1.html
_____________________
i've got nothing. ;)
Belenos Stardust
Registered User
Join date: 1 Nov 2006
Posts: 10
05-03-2007 07:44
What no reggae? I'm hurt!