Welcome, Guest |
You have to register before you can post on our site.
|
|
|
FreeView 1.2 WebGuide (revision 3) |
Posted by: ☠ MosDef ☠ - 02-21-2013, 12:02 AM - Forum: Communication Scripts
- No Replies
|
|
Multifunctional Picture viewer and Video control script with webguide support
This script is distributed for free and must stay that way.
*** DO NOT SELL THIS SCRIPT UNDER ANY CIRCUMSTANCE. ***
Help for using this script can be obtained at: [To see links please register here]
Feel free to modify this script and post your improvement. Leave the credits intact but feel free to add your name at its bottom.
Whats new:
Now using FULL_BRIGHT instead of PRIM_MATERIAL_LIGHT for the screen display
Added an ownership-change code to handle cases where FreeView gets deeded to group post Video Init.
Renamed WebGuide to TV-Guide to reflect what this thing does better.
Added a 'Fix Scale' button to Picture mode to help against user texture-scale changes.
Additional minor help-tips and code improvements
Enjoy!
Code: /*
CrystalShard Foo presents...
FreeView 1.2 WebGuide (revision 3)
Tags: scripts, xml-rpc, avatar, chat, communications, dialog, dataserver, deprecated, detection, group, inventory, math, media, movement, notecard, light, owner, parcel, primitive, texture, time, timer, touch, video, xmlrpc, featured
Description: Multifunctional Picture viewer and Video control script with webguide support
This script is distributed for free and must stay that way.
*** DO NOT SELL THIS SCRIPT UNDER ANY CIRCUMSTANCE. ***
Help for using this script can be obtained at: http://www.slguide.com/help
Feel free to modify this script and post your improvement. Leave the credits intact but feel free to add your name at its bottom.
Whats new:
Now using FULL_BRIGHT instead of PRIM_MATERIAL_LIGHT for the screen display
Added an ownership-change code to handle cases where FreeView gets deeded to group post Video Init.
Renamed WebGuide to TV-Guide to reflect what this thing does better.
Added a 'Fix Scale' button to Picture mode to help against user texture-scale changes.
Additional minor help-tips and code improvements
Enjoy!
License:
None
http://secondlife.coolminds.org
*/
//Constants
integer PICTURE_ROTATION_TIMER = 30; //In whole seconds
integer DISPLAY_ON_SIDE = ALL_SIDES; //Change this to change where the image will be displayed
key VIDEO_DEFAULT = "71b8ff26-087d-5f44-285b-d38df2e11a81"; //Test pattern - Used as default video texture when one is missing in parcel media
key BLANK = "5748decc-f629-461c-9a36-a35a221fe21f"; //Blank texture - Used when there are no textures to display in Picture mode
string NOTECARD = "bookmarks"; //Used to host URL bookmarks for video streams
integer VIDEO_BRIGHT = TRUE; //FULL_BRIGHT status for Video
integer PICTURE_BRIGHT = TRUE; //FULL_BRIGHT status for Picture
integer REMOTE_CHANNEL = 9238742;
integer mode = 0; //Freeview mode.
//Mode 0 - Power off
//Mode 1 - Picture viewer
//Mode 2 - Video
integer listenHandle = -1; //Dialog menu listen handler
integer listenUrl = -1; //listen handler for channel 1 for when a URL is being added
integer listenTimer = -1; //Timer variable for removing all listeners after 2 minutes of listener inactivity
integer listenRemote = -1; //listen handler for the remote during initial setup
integer encryption = 0;
integer numberofnotecardlines = 0; //Stores the current number of detected notecard lines.
integer notecardline = 0; //Current notecard line
integer loop_image = FALSE; //Are we looping pictures with a timer? (picture mode)
integer current_texture = 0; //Current texture number in inventory being displayed (picture mode)
integer chan; //llDialog listen channel
integer notecardcheck = 0;
key video_texture; //Currently used video display texture for parcel media stream
string moviename;
string tempmoviename;
key notecardkey = NULL_KEY;
key tempuser; //Temp key storge variable
string tempurl; //Temp string storge variable
integer isGroup = TRUE;
key groupcheck = NULL_KEY;
key last_owner;
key XML_channel;
pictures() //Change mode to Picture Viewer
{
//Initilize variables
//Change prim to Light material while coloring face 0 black to prevent light-lag generation.
llSetPrimitiveParams([PRIM_BUMP_SHINY, DISPLAY_ON_SIDE, PRIM_SHINY_NONE, PRIM_BUMP_NONE, PRIM_COLOR, DISPLAY_ON_SIDE, <1,1,1>, 1.0, PRIM_MATERIAL, PRIM_MATERIAL_PLASTIC, PRIM_FULLBRIGHT, DISPLAY_ON_SIDE, PICTURE_BRIGHT]);
integer check = llGetInventoryNumber(INVENTORY_TEXTURE);
if(check == 0)
{
report("No pictures found.");
llSetTexture(BLANK,DISPLAY_ON_SIDE);
return;
}
else
if(current_texture > check)
//Set to first texture if available
current_texture = 0;
display_texture(current_texture);
}
video() //Change mode to Video
{
//Change prim to Light material while coloring face 0 black to prevent light-lag generation.
llSetPrimitiveParams([PRIM_BUMP_SHINY, DISPLAY_ON_SIDE, PRIM_SHINY_NONE, PRIM_BUMP_NONE, PRIM_COLOR, DISPLAY_ON_SIDE, <1,1,1>, 1.0, PRIM_MATERIAL, PRIM_MATERIAL_PLASTIC, PRIM_FULLBRIGHT, DISPLAY_ON_SIDE, VIDEO_BRIGHT, PRIM_TEXTURE, DISPLAY_ON_SIDE, "62dc73ca-265f-7ca0-0453-e2a6aa60bb6f", llGetTextureScale(DISPLAY_ON_SIDE), llGetTextureOffset(DISPLAY_ON_SIDE), llGetTextureRot(DISPLAY_ON_SIDE)]);
report("Video mode"+moviename+": Stopped");
if(finditem(NOTECARD) != -1)
tempuser = llGetNumberOfNotecardLines(NOTECARD);
video_texture = llList2Key(llParcelMediaQuery([PARCEL_MEDIA_COMMAND_TEXTURE]),0);
if(video_texture == NULL_KEY)
{
video_texture = VIDEO_DEFAULT;
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_TEXTURE,VIDEO_DEFAULT]);
llSay(0,"No parcel media texture found. Setting texture to default: "+(string)VIDEO_DEFAULT);
if(llGetLandOwnerAt(llGetPos()) != llGetOwner())
llSay(0,"Error: Cannot modify parcel media settings. "+llGetObjectName()+" is not owned by parcel owner.");
}
llSetTexture(video_texture,DISPLAY_ON_SIDE);
}
off()
{
report("Click to power on.");
llSetPrimitiveParams([PRIM_BUMP_SHINY, DISPLAY_ON_SIDE, PRIM_SHINY_LOW, PRIM_BUMP_NONE, PRIM_COLOR, DISPLAY_ON_SIDE, <0.1,0.1,0.1>, 1.0,PRIM_MATERIAL, PRIM_MATERIAL_PLASTIC, PRIM_FULLBRIGHT, DISPLAY_ON_SIDE, FALSE, PRIM_TEXTURE, DISPLAY_ON_SIDE, BLANK, llGetTextureScale(DISPLAY_ON_SIDE), llGetTextureOffset(DISPLAY_ON_SIDE), llGetTextureRot(DISPLAY_ON_SIDE)]);
}
integer finditem(string name) //Finds and returns an item's inventory number
{
integer i;
for(i=0;i<llGetInventoryNumber(INVENTORY_NOTECARD);i++)
if(llGetInventoryName(INVENTORY_NOTECARD,i) == NOTECARD)
return i;
return -1;
}
seturl(string url, key id) //Set parcel media URL
{
if(mode != 2)
{
video();
mode = 2;
}
moviename = tempmoviename;
if(moviename)
moviename = " ["+moviename+"]";
tempmoviename = "";
string oldurl = llList2String(llParcelMediaQuery([PARCEL_MEDIA_COMMAND_URL]),0);
if(oldurl != "")
llOwnerSay("Setting new media URL. The old URL was: "+oldurl);
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_URL,url]);
if(id!=NULL_KEY)
menu(id);
else
{
report("Video mode"+moviename+": Playing");
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PLAY]);
}
if(isGroup)
llSay(0,"New media URL set.");
else
llOwnerSay("New media URL set: "+url);
}
string mediatype(string ext) //Returns a string stating the filetype of a file based on file extension
{
ext = llToLower(ext);
if(ext == "swf")
return "Flash";
if(ext == "mov" || ext == "avi" || ext == "mpg" || ext == "mpeg" || ext == "smil")
return "Video";
if(ext == "jpg" || ext == "mpeg" || ext == "gif" || ext == "png" || ext == "pict" || ext == "tga" || ext == "tiff" || ext == "sgi" || ext == "bmp")
return "Image";
if(ext == "txt")
return "Text";
if(ext == "mp3" || ext == "wav")
return "Audio";
return "Unknown";
}
browse(key id) //Image browser function for picture viewer mode
{
integer check = llGetInventoryNumber(INVENTORY_TEXTURE);
string header;
if(check > 0)
header = "("+(string)(current_texture+1)+"/"+(string)check+") "+llGetInventoryName(INVENTORY_TEXTURE,current_texture);
else
header = "No pictures found.";
llDialog(id,"** Monitor Control **\n Picture Viewer mode\n- Image browser\n- "+header,["Back","Next","Menu"],chan);
extendtimer();
}
report(string str)
{
llSetObjectDesc(str);
}
extendtimer() //Add another 2 minute to the Listen Removal timer (use when a Listen event is triggered)
{
if(listenHandle == -1)
listenHandle = llListen(chan,"","","");
listenTimer = (integer)llGetTime() + 120;
if(loop_image == FALSE)
llSetTimerEvent(45);
}
config(key id) //Configuration menu
{
extendtimer();
llDialog(id,"Current media URL:\n"+llList2String(llParcelMediaQuery([PARCEL_MEDIA_COMMAND_URL]),0)+"\nTip: If the picture is abit off, try 'Align ON'",["Set URL","Align ON","Align OFF","Menu","Set Remote"],chan);
}
tell_remote(string str)
{
llShout(REMOTE_CHANNEL,llXorBase64Strings(llStringToBase64((string)encryption + str), llStringToBase64((string)encryption)));
}
menu(key id) //Dialog menus for all 3 modes
{
list buttons = [];
string title = "** Monitor control **";
extendtimer();
if(mode != 0)
{
if(mode == 1) //Pictures menu
{
title+="\n Picture Viewer mode";
buttons+=["Browse"];
if(loop_image == FALSE)
buttons+=["Loop"];
else
buttons+=["Unloop"];
buttons+=["Video","Power off","Help","Fix scale"];
}
else //Video menu
{
title+="\n Video display mode\n"+moviename+"\nTip:\nClick 'TV Guide' to view the Online bookmarks.";
buttons+=["Pictures","Configure","Power off","Loop","Unload","Help","Play","Stop","Pause","TV Guide","Bookmarks","Set URL"];
}
}
else
buttons += ["Pictures","Video","Help"];
llDialog(id,title,buttons,chan);
}
display_texture(integer check) //Display texture and set name in description (picture mode)
{ //"Check" holds the number of textures in contents. The function uses "current_texture" to display.
string name = llGetInventoryName(INVENTORY_TEXTURE,current_texture);
llSetTexture(name,DISPLAY_ON_SIDE);
report("Showing picture: "+name+" ("+(string)(current_texture+1)+"/"+(string)check+")");
}
next() //Change to next texture (picture mode)
{ //This function is used twice - by the menu and timer. Therefor, it is a dedicated function.
current_texture++;
integer check = llGetInventoryNumber(INVENTORY_TEXTURE);
if(check == 0)
{
llSetTexture(BLANK,DISPLAY_ON_SIDE);
current_texture = 0;
report("No pictures found.");
return;
}
if(check == current_texture)
current_texture = 0;
display_texture(check);
return;
}
default
{
state_entry()
{
chan = (integer)llFrand(1000) + 1000; //Pick a random listen channel for the listener
if(PICTURE_ROTATION_TIMER <= 0) //Ensure the value is no less or equal 0
PICTURE_ROTATION_TIMER = 1;
llListenRemove(listenHandle);
listenHandle = -1;
last_owner = llGetOwner();
groupcheck = llRequestAgentData(llGetOwner(),DATA_NAME);
off();
llOpenRemoteDataChannel();
}
on_rez(integer i)
{
llResetScript();
}
touch_start(integer total_number)
{
//-------------------------------------------------------------------------------
//Listen only to owner or group member. Edit this code to change access controls.
if(llDetectedKey(0) != llGetOwner() && llDetectedGroup(0) == FALSE)
return;
//-------------------------------------------------------------------------------
if(llGetOwnerKey(llGetKey()) != last_owner) //Sense if object has been deeded to group for Web Guide function
{
isGroup = TRUE;
last_owner = llGetOwner();
groupcheck = llRequestAgentData(llGetOwner(),DATA_NAME);
if(mode == 2)
{
llSay(0,"Detected change in ownership. Attempting to obtain current parcel media texture...");
video();
}
}
menu(llDetectedKey(0));
}
changed(integer change)
{
if(change == CHANGED_INVENTORY) //If inventory change
if(mode == 1) //If picture mode
{
integer check = llGetInventoryNumber(INVENTORY_TEXTURE);
if(check != 0)
{
current_texture = 0;
display_texture(check);
}
else
{
llSetTexture(BLANK,DISPLAY_ON_SIDE);
report("No pictures found.");
}
}
else
if(mode == 2) //If video mode
if(finditem(NOTECARD) != -1) //And bookmarks notecard present
if(notecardkey != llGetInventoryKey(NOTECARD))
tempuser = llGetNumberOfNotecardLines(NOTECARD); //Reload number of lines
}
listen(integer channel, string name, key id, string message)
{
if(message == "Pictures")
{
if(mode == 2)
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_STOP]);
pictures();
mode = 1;
menu(id);
return;
}
if(message == "Video")
{
video();
mode = 2;
menu(id);
return;
}
if(message == "Power off")
{
if(mode == 2)
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_UNLOAD]);
off();
mode = 0;
return;
}
if(message == "Help")
{
llSay(0,"Help documentation is available at: http://www.slguide.com/help");
if(isGroup)
{
if(id == NULL_KEY)
{
llSay(0,"FreeView cannot load help pages while set to group without the remote.");
llSay(0,"For further assistance, please consult: http://slguide.com/help");
}
else
tell_remote("HELP"+(string)id+(string)XML_channel);
}
else
llLoadURL(id,"Help pages for FreeView","http://www.slguide.com?c="+(string)XML_channel+"&help=1");
}
if(mode == 1)
{
if(message == "Browse")
{
loop_image = FALSE;
browse(id);
return;
}
if(message == "Next")
{
extendtimer();
next();
browse(id);
}
if(message == "Back")
{
extendtimer();
current_texture--;
integer check = llGetInventoryNumber(INVENTORY_TEXTURE);
if(check == 0)
{
llSetTexture(BLANK,DISPLAY_ON_SIDE);
current_texture = 0;
report("No pictures found.");
return;
}
if(current_texture < 0)
current_texture = check - 1;
display_texture(check);
browse(id);
return;
}
if(message == "Menu")
{
menu(id);
return;
}
if(message == "Loop")
{
llSetTimerEvent(PICTURE_ROTATION_TIMER);
loop_image = TRUE;
llOwnerSay("Picture will change every "+(string)PICTURE_ROTATION_TIMER+" seconds.");
return;
}
if(message == "Unloop")
{
loop_image = FALSE;
llOwnerSay("Picture loop disabled.");
return;
}
if(message == "Fix scale")
{
llSay(0,"Setting display texture to 1,1 repeats and 0,0 offset.");
llScaleTexture(1, 1, DISPLAY_ON_SIDE);
llOffsetTexture(0, 0, DISPLAY_ON_SIDE);
return;
}
}
if(mode == 2)
{
if(channel == REMOTE_CHANNEL)
{
if(encryption == 0)
encryption = (integer)message;
llListenRemove(listenRemote);
listenRemote = -1;
llSay(0,"Remote configured ("+(string)id+")");
}
if(message == "TV Guide")
{
if(isGroup)
{
if(!encryption)
{
llSay(0,"** Error - This FreeView object has been deeded to group. You must use a Remote control to open the TV Guide.");
llSay(0,"You can set up the remote control from the Video -> Configuration menu. Please refer to the notecard for further assistance.");
return;
}
tell_remote((string)id+(string)XML_channel+(string)llGetOwner());
}
else
llLoadURL(id, "Come to the Guide to Start Your Viewer Playing!", "http://slguide.com/index.php?v=" + (string)llGetKey() + "&c=" + (string)XML_channel + "&o=" + (string)llGetOwner() + "&");
return;
}
string header = "Video mode"+moviename+": ";
if(message == "<< Prev")
{
notecardline--;
if(notecardline < 0)
notecardline = numberofnotecardlines - 1;
tempuser = id;
llGetNotecardLine(NOTECARD,notecardline);
return;
}
if(message == "Next >>")
{
notecardline++;
if(notecardline >= numberofnotecardlines)
notecardline = 0;
tempuser = id;
llGetNotecardLine(NOTECARD,notecardline);
return;
}
if(message == "Use")
{
if(tempurl == "** No URL specified! **")
tempurl = "";
seturl(tempurl,id);
return;
}
if(message == "Menu")
{
menu(id);
return;
}
if(message == "Configure")
{
config(id);
return;
}
if(message == "Bookmarks")
{
if(notecardcheck != -1)
{
llDialog(id,"Error: No valid bookmark data found in notecard '"+NOTECARD+"'.",["Menu"],chan);
return;
}
if(finditem(NOTECARD) != -1)
{
tempuser = id;
if(numberofnotecardlines < notecardline)
notecardline = 0;
llGetNotecardLine(NOTECARD,notecardline);
}
else
llDialog(id,"Error: No notecard named "+NOTECARD+" found in contents.",["Menu"],chan);
return;
}
if(llGetLandOwnerAt(llGetPos()) != llGetOwner()) //If we do not have permissions to actually do the following functions
{
llSay(0,"Error: Cannot modify parcel media settings. "+llGetObjectName()+" is not owned by parcel owner.");
menu(id);
return; //Abort
}
if(listenUrl != -1 && channel == 1) //Incoming data from "Set URL" command (user spoke on channel 1)
{
llListenRemove(listenUrl);
listenUrl = -1;
tempmoviename = "";
seturl(message,id);
}
if(message == "Play")
{
report(header+"Playing");
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PLAY]);
return;
}
if(message == "Stop")
{
report(header+"Stopped");
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_STOP]);
return;
}
if(message == "Pause")
{
report(header+"Paused");
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PAUSE]);
return;
}
if(message == "Unload")
{
report(header+"Stopped");
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_UNLOAD]);
return;
}
if(message == "Loop")
{
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_LOOP]);
return;
}
//URL , Auto-Scale,
if(message == "Set URL")
{
report(header+"Stopped");
listenUrl = llListen(1,"",id,"");
llDialog(id,"Please type the URL of your choice with /1 in thebegining. For example, /1 www.google.com",["Ok"],938);
return;
}
if(message == "Align ON")
{
report(header+"Stopped");
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_AUTO_ALIGN,TRUE]);
menu(id);
return;
}
if(message == "Align OFF")
{
report(header+"Stopped");
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_AUTO_ALIGN,FALSE]);
menu(id);
return;
}
if(message == "Set Remote")
{
llSay(0,"Configuring remote...");
encryption = 0;
llListenRemove(listenRemote);
listenRemote = llListen(REMOTE_CHANNEL,"","","");
llSay(REMOTE_CHANNEL,"SETUP");
}
}
}
dataserver(key queryid, string data)
{
if(queryid == groupcheck) //Test if object is deeded to group
{
groupcheck = NULL_KEY;
isGroup = FALSE;
return;
}
if(queryid == tempuser) //If just checking number of notecard lines
{
numberofnotecardlines = (integer)data;
notecardkey = llGetInventoryKey(NOTECARD);
notecardcheck = 0;
llGetNotecardLine(NOTECARD,notecardcheck);
return;
}
if(notecardcheck != -1)
{
if(data != EOF)
{
if(data == "")
{
notecardcheck++;
llGetNotecardLine(NOTECARD,notecardcheck);
}
else
{
notecardcheck = -1;
return;
}
}
else
return;
}
if(data == "" && notecardline < numberofnotecardlines) //If user just pressed "enter" in bookmarks, skip
{
notecardline++;
llGetNotecardLine(NOTECARD,notecardline);
return;
}
if(data == EOF)
{
notecardline = 0;
llGetNotecardLine(NOTECARD,notecardline);
return;
}
list parsed = llParseString2List(data,["|","| "," |"," | "],[]); //Ensure no blank spaces before "http://".
string name = llList2String(parsed,0);
tempurl = llList2String(parsed,1);
if(tempurl == "")
tempurl = "** No URL specified! **";
tempmoviename = name;
llDialog(tempuser,"Bookmarks notecard ("+(string)(notecardline+1)+"/"+(string)numberofnotecardlines+")\n"+name+" ("+mediatype(llList2String(llParseString2List(tempurl,["."],[]),-1))+")\n"+tempurl,["<< Prev","Use","Next >>","Menu"],chan);
}
remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
{
if (type == REMOTE_DATA_CHANNEL)
{
XML_channel = channel;
}
else if(type == REMOTE_DATA_REQUEST)
{
list media_info = llParseString2List(sval, ["|"], []);
tempmoviename = llList2String(media_info,0);
seturl(llList2String(media_info,1),NULL_KEY);
llRemoteDataReply(channel, message_id, sval, 1);
}
}
timer()
{
if(llGetTime() > listenTimer) //If listener time expired...
{
llListenRemove(listenHandle); //Remove listeneres.
llListenRemove(listenUrl);
llListenRemove(listenRemote);
listenHandle = -1;
listenUrl = -1;
listenRemote = -1;
listenTimer = -1;
if(loop_image == FALSE || mode != 1) //If we're not looping pictures or are in picture mode at all
llSetTimerEvent(0.0); //Remove timer
}
if(loop_image == TRUE && mode == 1) //If we're looping pictures and and we're in picture mode...
next(); //Next picture
}
}
|
|
|
Parcel Analyzer |
Posted by: ☠ MosDef ☠ - 02-20-2013, 11:55 PM - Forum: Business Scripts
- Replies (3)
|
|
Code: /*
Bornslippy Ruby presents...
Parcel Analyzer
Tags: avatar, effects, ground, group, math, owner, parcel, primitive, region, text, time, timer, world, featured, tools
Description:
License:
http://secondlife.coolminds.org
*/
vector Color = <0, .5, 0>;
float UpdateInterval = 60.0;
integer UTCOffset = 1;
list Days = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"];
list Months = ["January", "Febrary", "March", "April", "May", "June", "July", "Agoust", "September", "October", "November", "December"];
string Parcel;
integer llAirPressure()
{
vector Position = llGetPos();
float Base_Reading = llLog10(5- (((Position.z - llWater(ZERO_VECTOR)) + 10.0)/15500));
float KiloPascal = (101.32500 + Base_Reading);
return (integer)KiloPascal;
}
string GetDay(integer offset)
{
return llList2String(Days, ((((llGetUnixTime()/3600) + offset)/24)%7));
}
string GetMonth(integer month)
{
return llList2String( ( [""] + Months ), month );
}
Refresh()
{
if ( Parcel == "" )
{
list flags = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME,PARCEL_DETAILS_DESC,PARCEL_DETAILS_OWNER,PARCEL_DETAILS_GROUP,PARCEL_DETAILS_AREA]);
Parcel = "[Parcel: " + llList2String( flags, 0 ) + "]\n";
if ( llList2String( flags, 1 ) != "" )
Parcel += "[Description: " + llList2String( flags, 1 ) + "]\n";
if ( llKey2Name( llList2Key( flags, 2 ) ) != "" )
Parcel += "[Owner: " + llKey2Name( llList2Key( flags, 2 ) ) + "]\n";
if ( llKey2Name( (key)llList2String( flags, 3 ) ) != "" )
Parcel += "[Group: " + llKey2Name( (key)llList2String( flags, 3 ) ) + "]\n";
Parcel += "[Size: " + llList2String( flags, 4 ) + " sqm.]";
}
list timestamp = llParseString2List(llGetTimestamp(),["T",":",":","."],[]);
list date = llParseString2List(
llList2String(timestamp, 0),
["-"],
[]);
vector pos = llGetPos();
vector windVector = llWind(pos);
float wind;
if ( windVector.x > windVector.y ) wind = windVector.x;
else wind = windVector.y;
string sign;
if ( UTCOffset > 0 ) sign = "+";
else sign = "-";
string text = (string)(llList2Integer(timestamp,1) + UTCOffset) + ":" + llList2String(timestamp,2 ) + " UTC"+sign+(string)UTCOffset+"\n" +
GetDay(1) + " " + llList2String(date, 2) + " " + GetMonth((integer)llList2String(date, 1)) + " " + llList2String(date, 0) + "\n" +
"[Parcel Informations]\n"+Parcel+"\n[Pressure: " + (string)llAirPressure() + " KiloPascal]" + "[Altitude: " + (string)((integer)pos.z) + " Meters][Wind: " + (string) wind +"]\n" +
"[Sun: n/a]\n";
llSetText(text, Color, 1);
}
default
{
state_entry()
{
llSetTimerEvent( UpdateInterval );
}
timer()
{
Refresh();
}
changed( integer _c )
{
if ( _c & CHANGED_REGION )
{
list flags = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME,PARCEL_DETAILS_DESC,PARCEL_DETAILS_OWNER,PARCEL_DETAILS_GROUP,PARCEL_DETAILS_AREA]);
Parcel = "[Parcel: " + llList2String( flags, 0 ) + "]\n";
if ( llList2String( flags, 1 ) != "" )
Parcel += "[Description: " + llList2String( flags, 1 ) + "]\n";
if ( llKey2Name( llList2Key( flags, 2 ) ) != "" )
Parcel += "[Owner: " + llKey2Name( llList2Key( flags, 2 ) ) + "]\n";
if ( llKey2Name( (key)llList2String( flags, 3 ) ) != "" )
Parcel += "[Group: " + llKey2Name( (key)llList2String( flags, 3 ) ) + "]\n";
Parcel += "[Size: " + llList2String( flags, 4 ) + " sqm.]";
}
}
}
|
|
|
UUID Sensor Private ( Channel 50 ) |
Posted by: ☠ MosDef ☠ - 02-20-2013, 11:52 PM - Forum: Avatar Augmentation Scripts
- No Replies
|
|
Code: /*
Bornslippy Ruby presents...
UUID Sensor Private ( Channel 50 )
Tags: chat, communications, detection, owner, sensor, featured, tools
Description:
License:
http://secondlife.coolminds.org
*/
default
{
state_entry()
{
llListen( 50, "", llGetOwner(), "start" );
}
listen( integer _c, string _n, key _k, string _m )
{
llSensor("", NULL_KEY, AGENT, 92.2, TWO_PI);
}
sensor(integer _n)
{
string Text = "\n";
integer x;
for (; x<_n; ++x)
Text += "\n" + (string) llDetectedKey(x) + " " + llDetectedName(x);
llOwnerSay( Text );
}
}
|
|
|
Swarm Script |
Posted by: ☠ MosDef ☠ - 02-20-2013, 11:45 PM - Forum: PARTICLES
- Replies (1)
|
|
This script is my implementation of the well-known swarm algorithm which can be found in numerous open-source programs.
Due to the specifics of the SL environment, I have strayed from some of the traditional rules slightly.
Regardless, the end effect is indistiguishable from the original algorithm.
Code: /*
Apotheus Silverman, Riptide Ramos presents...
Swarm Script
Tags: scripts, chat, collision, communications, damping, detection, ground, hover, movement, physics, primitive, region, rotation, sensor, time, vehicle, world, featured
Description:
// Swarm script
// by Apotheus Silverman
// with mods from Riptide Ramos
// This script is my implementation of the well-known swarm algorithm
// which can be found in numerous open-source programs.
// Due to the specifics of the SL environment, I have strayed from some
// of the traditional rules slightly. Regardless, the end effect is
// indistiguishable from the original algorithm.
This script is my implementation of the well-known swarm algorithm which can be found in numerous open-source programs.
Due to the specifics of the SL environment, I have strayed from some of the traditional rules slightly.
Regardless, the end effect is indistiguishable from the original algorithm.
License:
None
http://secondlife.coolminds.org
*/
// Configurable parameters
// Determines whether or not to enable STATUS_SANDBOX.
integer sandbox = FALSE;
// Timer length
float timer_length = 0.7;
// Die after this many seconds
integer kill_time = 300;
// How much force to apply with each impulse
float force_modifier = 1.0;
// How much force to apply when repulsed by another like me
float repulse_force_modifier = 0.5;
// How much friction to use on a scale from 0 to 1.
// Note that friction takes effect each timer cycle, so the lower the timer length,
// the more the friction you specify here will take effect, thereby increasing actual
// friction applied.
float friction = 0.6;
// How much to modify rotation damping. Higher numbers produce slower rotation.
float rotation_modifier = 80;
// Does this object "swim" in air or water?
// 2 = air
// 1 = water
// 0 = both
integer flight_mode = 2;
// *** Don't change anything below unless you *really* know what you're doing ***
// Collision function
collide(vector loc) {
vector mypos = llGetPos();
float mass = llGetMass();
// Apply repulse force
vector impulse = llVecNorm(mypos - loc);
llApplyImpulse(impulse * repulse_force_modifier * mass, FALSE);
// Update rotation
llLookAt(mypos + llGetVel(), mass * 0.5, mass * rotation_modifier);
}
// This function is called whether the sensor senses anything or not
sensor_any() {
// Die after reaching kill_time
if (kill_time != 0 && llGetTime() >= kill_time) {
llDie();
}
// Get my position and mass
vector mypos = llGetPos();
// Check for air/water breach
if (flight_mode == 1) {
// water
if (mypos.z >= llWater(mypos)) {
collide(<mypos.x, mypos.y, mypos.z + 0.3> );
}
} else if (flight_mode == 2) {
// air
if (mypos.z <= llWater(mypos)) {
collide(<mypos.x, mypos.y, mypos.z - 0.3> );
}
}
}
default {
state_entry() {
llSay(0, "Fishy spawned.");
// Sandbox
llSetStatus(STATUS_SANDBOX, sandbox);
llSetStatus(STATUS_BLOCK_GRAB, FALSE);
// Initialize physics behavior
llSetBuoyancy(1.0);
llSetStatus(STATUS_PHYSICS, TRUE);
llSetStatus(STATUS_PHANTOM, FALSE);
// Initialize sensor
llSensorRepeat(llGetObjectName(), NULL_KEY, ACTIVE|SCRIPTED, 96, PI, timer_length);
}
collision_start(integer total_number) {
collide(llDetectedPos(0));
}
land_collision_start(vector position) {
vector mypos = llGetPos();
collide(mypos - llGroundNormal(mypos));
}
no_sensor() {
sensor_any();
}
sensor(integer total_number) {
sensor_any();
// Populate neighbors with the positions of the two nearest neighbors.
vector mypos = llGetPos();
float mass = llGetMass();
list neighbors = [];
integer i;
vector v1;
vector v2;
float d1 = 100;
float d2 = 100;
for (i = 0; i < total_number; i++) {
vector current_pos = llDetectedPos(i);
float cur_dist = llVecDist(mypos, current_pos);
if ( cur_dist < d1 ) {
// Shift list down, take over top slot.
d2 = d1;
v2 = v1;
d1 = cur_dist;
v1 = current_pos;
} else if ( cur_dist < d2 ) {
// Replace second slot only
d2 = cur_dist;
v2 = current_pos;
}
}
// Process movement
// Apply friction
llApplyImpulse(-(llGetVel() * friction * mass), FALSE);
// Apply force
if (llGetListLength(neighbors) == 2) {
vector neighbor1 = llList2Vector(neighbors, 0);
vector neighbor2 = llList2Vector(neighbors, 1);
vector target = neighbor2 + ((neighbor1 - neighbor2) * 0.5);
vector impulse = llVecNorm(target - mypos);
llSetForce(impulse * force_modifier * mass, FALSE);
}
// Update rotation
llLookAt(llGetPos() + llGetVel(), mass * 0.5, mass * rotation_modifier);
}
on_rez(integer start_param) {
llResetTime();
}
}
|
|
|
YouTube Video Player |
Posted by: ☠ MosDef ☠ - 02-20-2013, 11:43 PM - Forum: Communication Scripts
- No Replies
|
|
Code: /*
Anonymous presents...
YouTube Video Player
Tags: scripts, chat, communications, media, movement, light, owner, parcel, primitive, texture, touch, video, featured
Description:
License:
None
http://secondlife.coolminds.org
*/
//send request to web server, get back a url
//set texture
//set parcel media url
string vidurl;
string vidid;
string homeurl;
key mediatexture = "d41f6ea7-e3d3-a8bf-d809-f7cfb52e4757";
string instructions = "Say YouTube links in chat to have them play.";
key httpid;
string VidID(string link)
{
integer index = llSubStringIndex(link, "v=");
return llGetSubString(link, index + 2, index + 12);
}
default
{
touch_start(integer num)
{
llSay(0, instructions);
}
state_entry()
{
llSetPrimitiveParams([PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_NONE, PRIM_BUMP_NONE, PRIM_COLOR, ALL_SIDES, <1,1,1>, 1.0, PRIM_MATERIAL, PRIM_MATERIAL_PLASTIC, PRIM_FULLBRIGHT, ALL_SIDES, 1, PRIM_TEXTURE, ALL_SIDES, NULL_KEY, llGetTextureScale(2), llGetTextureOffset(2), llGetTextureRot(2)]);
llSetTexture(mediatexture, ALL_SIDES);
if (llGetOwner() == llGetLandOwnerAt(llGetPos()))
{
llListen(0, "", NULL_KEY, "");
llListen(1, "", NULL_KEY, "");
llSay(0, instructions);
}
else
{
llSay(0, "Error: I am not owned by the landowner. If the land is group owned, I need to be deeded to group.");
}
}
on_rez(integer param)
{
llResetScript();
}
changed(integer change)
{
if (change & CHANGED_OWNER)
{
llResetScript();
}
}
listen(integer channel, string name, key id, string message)
{
if (~llSubStringIndex(message, "http://www.youtube") || ~llSubStringIndex(message, "http://youtube")||~llSubStringIndex(message, "https://www.youtube") || ~llSubStringIndex(message, "https://youtube"))
{
list params;
string vidid;
//turn the data into a vidid
vidid = VidID(message);
//llOwnerSay(vidid);
string hd;
if (channel == 1) hd = ".mp4?fs=1";
else hd = ".mp4";
homeurl = "http://www.youtubemp4.com/video/" + vidid + hd;
params = [PARCEL_MEDIA_COMMAND_URL, homeurl];
params += [PARCEL_MEDIA_COMMAND_TYPE, "video/mp4"];
llParcelMediaCommandList(params);
llSay(0, "Playing " + message + ". Push play on your viewer.");
}
}
}
|
|
|
Rose Firefly Particles |
Posted by: ☠ MosDef ☠ - 02-20-2013, 11:08 PM - Forum: PARTICLES
- No Replies
|
|
Code: /*
Anonymous presents...
Rose Firefly Particles
Tags: effects, owner, particles, primitive
Description:
License:
None
http://secondlife.coolminds.org
*/
// Mask Flags - set to TRUE to enable
integer glow = TRUE; // Make the particles glow
integer bounce = FALSE; // Make particles bounce on Z plan of object
integer interpColor = TRUE; // Go from start to end color
integer interpSize = TRUE; // Go from start to end size
integer wind = TRUE; // Particles effected by wind
integer followSource = FALSE; // Particles follow the source
integer followVel = TRUE; // Particles turn to velocity direction
// Choose a pattern from the following:
// PSYS_SRC_PATTERN_EXPLODE
// PSYS_SRC_PATTERN_DROP
// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
// PSYS_SRC_PATTERN_ANGLE_CONE
// PSYS_SRC_PATTERN_ANGLE
integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;
// Select a target for particles to go towards
// "" for no target, "owner" will follow object owner
// and "self" will target this object
// or put the key of an object for particles to go to
key target = "";
// Particle paramaters
float age = .5; // Life of each particle
float maxSpeed = 0; // Max speed each particle is spit out at
float minSpeed = 0; // Min speed each particle is spit out at
string texture; // Texture used for particles, default used if blank
float startAlpha = 0.1; // Start alpha (transparency) value
float endAlpha = 1; // End alpha (transparency) value
vector startColor = <1.0, 0.0, 1.0>; // Start color of particles <R,G,B>
vector endColor = <1.0, 0.0, 1.0>; // End color of particles <R,G,B> (if interpColor == TRUE)
vector startSize = <.1,.1,.1>; // Start size of particles
vector endSize = <.1,.1,.1>; // End size of particles (if interpSize == TRUE)
vector push = <0,0,0>; // Force pushed on particles
// System paramaters
float rate = 0.1; // How fast (rate) to emit particles
float radius = .55; // Radius to emit particles for BURST pattern
integer count = 5; // How many particles to emit per BURST
float outerAngle = 1.55; // Outer angle for all ANGLE patterns
float innerAngle = 1.55; // Inner angle for all ANGLE patterns
vector omega = <0,0,3>; // Rotation of ANGLE patterns around the source
float life = 0; // Life in seconds for the system to make particles
// Script variables
integer flags;
updateParticles()
{
if (target == "owner") target = llGetOwner();
if (target == "self") target = llGetKey();
if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (wind) flags = flags | PSYS_PART_WIND_MASK;
if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;
llParticleSystem([ PSYS_PART_MAX_AGE,age,
PSYS_PART_FLAGS,flags,
PSYS_PART_START_COLOR, startColor,
PSYS_PART_END_COLOR, endColor,
PSYS_PART_START_SCALE,startSize,
PSYS_PART_END_SCALE,endSize,
PSYS_SRC_PATTERN, pattern,
PSYS_SRC_BURST_RATE,rate,
PSYS_SRC_ACCEL, push,
PSYS_SRC_BURST_PART_COUNT,count,
PSYS_SRC_BURST_RADIUS,radius,
PSYS_SRC_BURST_SPEED_MIN,minSpeed,
PSYS_SRC_BURST_SPEED_MAX,maxSpeed,
PSYS_SRC_TARGET_KEY,target,
PSYS_SRC_INNERANGLE,innerAngle,
PSYS_SRC_OUTERANGLE,outerAngle,
PSYS_SRC_OMEGA, omega,
PSYS_SRC_MAX_AGE, life,
PSYS_SRC_TEXTURE, texture,
PSYS_PART_START_ALPHA, startAlpha,
PSYS_PART_END_ALPHA, endAlpha
]);
}
default
{
state_entry()
{
updateParticles();
//llParticleSystem([]);
}
}
|
|
|
|