Trying to tweak this media switcher.
|
Gydeon Fox
Registered User
Join date: 4 Mar 2005
Posts: 148
|
05-29-2005 19:03
Okay, I found this free script in my travels. The problem is matching up the texture for the streams I'd like to show. I have a set of cartoons which are all the same size, so I've fiddled with the texture so they'll match the size of my tv screen.
The problem is, this script resets the texture settings and my cartoon gets stuck on the left side of the screen. I'm not much of a scripter, so I haven't identified the place where it does this. Could someone please point it out to me so I can keep my settings?
Thanks,
Gydeon.
|
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
|
05-30-2005 09:10
First of all, that huge unindented bit of code is horrificly unreadable. Next time you post code, please use the [/PHP] and brackets. Also, it would have been easier to just link it to the freeview post itself. Could you edit your post to take out the code, and just point to the freeview script?
To deal with the actual problem, I think you may be a bit confused. The Freeview script is mainly for setting up video streams and other stuff from the Internet. Is your cartoon on the internet, or did you just upload a bunch of textures to SL? Please explain exactly what you want, and maybe we can help.
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
05-30-2005 12:20
Here's the fixed indentation, I'm still reading through it though: //FreeView 1.0 - By CrystalShard Foo //Multifunctional Picture viewer and Video control script //This script is distributed for free and must stay that way. DO NOT SELL THIS SCRIPT UNDER ANY CIRCUMSTANCE.
//Feel free to modify this script and post your improvement. Leave the credits intact but feel free to add your name at its bottom.
//Constants float 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 = "0c40d39e-279c-8f9a-de61-36c99184a612"; //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 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 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
key tempuser; //Temp key storge variable string tempurl; //Temp string storge variable
pictures() //Change mode to Picture Viewer { //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_LIGHT]); llSetColor(<0,0,0>,0); //Initilize variables current_texture = 0; //Set to first texture if available integer check = llGetInventoryNumber(INVENTORY_TEXTURE); if(check > 0) display_texture(check); else { llSetObjectDesc("No pictures found."); llSetTexture(BLANK,DISPLAY_ON_SIDE); } }
video() //Change mode to Video { llSetObjectDesc("Video mode: 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,"Parcel media texture not 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."); } //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_LIGHT,PRIM_TEXTURE,DISPLAY_ON_SIDE,video_texture,<1,1,0>,<0,0,0>,TWO_PI]); llSetColor(<0,0,0>,0); }
off() { llSetObjectDesc("Touch Screen to Start."); 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_TEXTURE,DISPLAY_ON_SIDE,BLANK,<1,1,0>,<0,0,0>,TWO_PI]); }
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 { string oldurl = llList2String(llParcelMediaQuery([PARCEL_MEDIA_COMMAND_URL]),0); if(oldurl != "") llOwnerSay("Changing Channel. The old channelwas: "+oldurl); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_URL,url]); menu(id); llOwnerSay("Streaming URL set."); }
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"; 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(); }
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),["Set URL","Align ON","Align OFF","Menu"],chan); }
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+=["Back","Next"]; buttons+=["Browse"]; if(loop_image == FALSE) buttons+=["Loop"]; else buttons+=["Unloop"]; buttons+=["Video","Power off"]; } else //Video menu { title+="\n Video display mode"; buttons+=["Configure","Bookmarks","Power off","Pause","Unload","Pictures","Play","Stop","Loop"]; } } else buttons += ["Pictures","Video"]; 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); llSetObjectDesc("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; llSetObjectDesc("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; off(); } 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; //-------------------------------------------------------------------------------
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); llSetObjectDesc("No pictures found."); } } else if(mode == 2) //If video mode if(finditem(NOTECARD) != -1) //And bookmarks notecard present 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(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; llSetObjectDesc("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(mode == 2) { string header = "Video mode: "; 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 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; seturl(message,id); } if(message == "Play") { llSetObjectDesc(header+"Playing"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PLAY]); return; } if(message == "Stop") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_STOP]); return; } if(message == "Pause") { llSetObjectDesc(header+"Paused"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PAUSE]); return; } if(message == "Unload") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_UNLOAD]); return; } if(message == "Loop") { llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_LOOP]); return; } //URL , Auto-Scale, if(message == "Set URL") { llSetObjectDesc(header+"Stopped"); listenurl = llListen(1,"",id,""); // llInstantMessage(llGetOwner(),"Please type the URL of your choice with /1 at the begining. For example, /1 www.google.com"); 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") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_AUTO_ALIGN,TRUE]); menu(id); return; } if(message == "Align OFF") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_AUTO_ALIGN,FALSE]); menu(id); return; } } } dataserver(key queryid, string data) { if(queryid == tempuser) //If just checking number of notecard lines { numberofnotecardlines = (integer)data; 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! **"; llDialog(tempuser,"Bookmarks notecard ("+(string)(notecardline+1)+"/"+(string)numberofnotecardlines+")\n"+name+" ("+mediatype(llList2String(llParseString2List(tempurl,["."],[]),-1))+")\n"+tempurl,["<< Prev","Use","Next >>","Menu"],chan); } timer() { if(llGetTime() > listenTimer) //If listener time expired... { llListenRemove(listenHandle); //Remove listeneres. llListenRemove(listenurl); listenHandle = -1; listenurl = -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 } }
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
05-30-2005 12:38
Your problem is probably happening within these two functions: video() //Change mode to Video { llSetObjectDesc("Video mode: 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,"Parcel media texture not 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."); } //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_LIGHT,PRIM_TEXTURE,DISPLAY_ON_SIDE,video_texture,<1,1,0>,<0,0,0>,TWO_PI]); llSetColor(<0,0,0>,0); }
off() { llSetObjectDesc("Touch Screen to Start."); 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_TEXTURE,DISPLAY_ON_SIDE,BLANK,<1,1,0>,<0,0,0>,TWO_PI]); }
The script changes the prim's color, texture and material to turn the display off and on. By using llSetPrimitiveParams to do this, the script also inadvertantly changes the offset and scale that have been set by the user in edit mode. Changing these two functions so that they look like this might fix that: video() //Change mode to Video { llSetObjectDesc("Video mode: 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,"Parcel media texture not 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."); } //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_LIGHT,PRIM_TEXTURE,DISPLAY_ON_SIDE,video_texture,llGetTextureScale(),llGetTextureOffset(),llGetTextureRot()]); llSetColor(<0,0,0>,0); }
off() { llSetObjectDesc("Touch Screen to Start."); 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_TEXTURE,DISPLAY_ON_SIDE,BLANK,llGetTextureScale(),llGetTextureOffset(),llGetTextureRot()]); }
Im not 100% sure that llGetTextureScale(), llGetTextureOffset(), and llGetTextureRot() map exactly to the llSetPrimitiveParams parameters specifying repeats, offset and rotation (respectively), but that's the most logical mapping I can think of atm. Alternatively, you can extract the texture params before setting them using llGetPrimitiveParams([PRIM_TEXTURE]), change only the values in the list that correspond to the texture key, *then* set them using llSetPrimitiveParams, but the above (if it works) it more efficiant. And here's the complete fixed script: //FreeView 1.0 - By CrystalShard Foo //Multifunctional Picture viewer and Video control script //This script is distributed for free and must stay that way. DO NOT SELL THIS SCRIPT UNDER ANY CIRCUMSTANCE.
//Feel free to modify this script and post your improvement. Leave the credits intact but feel free to add your name at its bottom.
//Constants float 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 = "0c40d39e-279c-8f9a-de61-36c99184a612"; //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 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 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
key tempuser; //Temp key storge variable string tempurl; //Temp string storge variable
pictures() //Change mode to Picture Viewer { //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_LIGHT]); llSetColor(<0,0,0>,0); //Initilize variables current_texture = 0; //Set to first texture if available integer check = llGetInventoryNumber(INVENTORY_TEXTURE); if(check > 0) display_texture(check); else { llSetObjectDesc("No pictures found."); llSetTexture(BLANK,DISPLAY_ON_SIDE); } }
video() //Change mode to Video { llSetObjectDesc("Video mode: 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,"Parcel media texture not 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."); } //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_LIGHT,PRIM_TEXTURE,DISPLAY_ON_SIDE,video_texture,llGetTextureScale(),llGetTextureOffset(),llGetTextureRot()]); llSetColor(<0,0,0>,0); }
off() { llSetObjectDesc("Touch Screen to Start."); 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_TEXTURE,DISPLAY_ON_SIDE,BLANK,llGetTextureScale(),llGetTextureOffset(),llGetTextureRot()]); }
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 { string oldurl = llList2String(llParcelMediaQuery([PARCEL_MEDIA_COMMAND_URL]),0); if(oldurl != "") llOwnerSay("Changing Channel. The old channelwas: "+oldurl); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_URL,url]); menu(id); llOwnerSay("Streaming URL set."); }
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"; 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(); }
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),["Set URL","Align ON","Align OFF","Menu"],chan); }
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+=["Back","Next"]; buttons+=["Browse"]; if(loop_image == FALSE) buttons+=["Loop"]; else buttons+=["Unloop"]; buttons+=["Video","Power off"]; } else //Video menu { title+="\n Video display mode"; buttons+=["Configure","Bookmarks","Power off","Pause","Unload","Pictures","Play","Stop","Loop"]; } } else buttons += ["Pictures","Video"]; 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); llSetObjectDesc("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; llSetObjectDesc("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; off(); } 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; //-------------------------------------------------------------------------------
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); llSetObjectDesc("No pictures found."); } } else if(mode == 2) //If video mode if(finditem(NOTECARD) != -1) //And bookmarks notecard present 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(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; llSetObjectDesc("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(mode == 2) { string header = "Video mode: "; 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 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; seturl(message,id); } if(message == "Play") { llSetObjectDesc(header+"Playing"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PLAY]); return; } if(message == "Stop") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_STOP]); return; } if(message == "Pause") { llSetObjectDesc(header+"Paused"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PAUSE]); return; } if(message == "Unload") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_UNLOAD]); return; } if(message == "Loop") { llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_LOOP]); return; } //URL , Auto-Scale, if(message == "Set URL") { llSetObjectDesc(header+"Stopped"); listenurl = llListen(1,"",id,""); // llInstantMessage(llGetOwner(),"Please type the URL of your choice with /1 at the begining. For example, /1 www.google.com"); 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") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_AUTO_ALIGN,TRUE]); menu(id); return; } if(message == "Align OFF") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_AUTO_ALIGN,FALSE]); menu(id); return; } } } dataserver(key queryid, string data) { if(queryid == tempuser) //If just checking number of notecard lines { numberofnotecardlines = (integer)data; 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! **"; llDialog(tempuser,"Bookmarks notecard ("+(string)(notecardline+1)+"/"+(string)numberofnotecardlines+")\n"+name+" ("+mediatype(llList2String(llParseString2List(tempurl,["."],[]),-1))+")\n"+tempurl,["<< Prev","Use","Next >>","Menu"],chan); } timer() { if(llGetTime() > listenTimer) //If listener time expired... { llListenRemove(listenHandle); //Remove listeneres. llListenRemove(listenurl); listenHandle = -1; listenurl = -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 } }
One of the things I really dislike about this script is that it changes the prim's material to light. Unless you *really* need to enhance the brightness of the film, you shouldn't use light prims unnecessarily. ==Chris
|
Gydeon Fox
Registered User
Join date: 4 Mar 2005
Posts: 148
|
05-31-2005 16:29
From: Keknehv Psaltery First of all, that huge unindented bit of code is horrificly unreadable. Next time you post code, please use the and brackets. Also, it would have been easier to just link it to the freeview post itself. Could you edit your post to take out the code, and just point to the freeview script? [/PHP] Sorry about that. Didn't know those tags. I'll use those in the future.  From: Keknehv Psaltery To deal with the actual problem, I think you may be a bit confused. The Freeview script is mainly for setting up video streams and other stuff from the Internet. Is your cartoon on the internet, or did you just upload a bunch of textures to SL? Please explain exactly what you want, and maybe we can help. I know that this script is for video, but I can see where calling them "cartoons" may have confused the reader. This thing does have a picture mode after all.  Anyway, these aren't comic strip cartoons, like in the newspaper. They're old cartoon movie serials from the internet. From: Christopher Omega One of the things I really dislike about this script is that it changes the prim's material to light. Unless you *really* need to enhance the brightness of the film, you shouldn't use light prims unnecessarily.
First of all, thanks for indenting the script. Second, thanks for the fix. I'll try it out as soon as I can. Third, are light prims really that bad? I'm rebuilding my home with a few lamps because I have my night-time darkness down low, but if they're really laggy or something maybe I'll limit the number. And if the screen's going to be a light prim, then I guess I don't need a lamp in that room... Gydeon.
|
Gydeon Fox
Registered User
Join date: 4 Mar 2005
Posts: 148
|
05-31-2005 23:02
Having a problem with this bit, where it's switching to video mode. Whatever's wrong, it's probably wrong on the picture mode as well, but of course I didn't get that far. I'm getting this error line, which places the cursor inside the "llGetTextureScale()" (71, 223) : ERROR : Function call mismatches type or numer of arguments I'm also planning to change "Light" to "Wood" once I get this thing working, since I don't need the screen to be a light source. Gydeon. } //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_LIGHT,PRIM_TEXTURE,DISPLAY_ON_SIDE,video_texture,llGetTextureScale(),llGetTextureOffset(),llGetTextureRot()]); llSetColor(<0,0,0>,0); }
|
Gydeon Fox
Registered User
Join date: 4 Mar 2005
Posts: 148
|
Found it right in front of me. Where's my head lately?
05-31-2005 23:13
Okay, here's a link to the original thread. I found mine in a freebie TV, don't know why I didn't think to scour the Library properly. Probably my night job + my new 8am class... been a coffee zombie lately. /15/81/41140/1.htmlAlso, I've found that the original script isn't a problem anymore if I check the box for auto-scaling content. My screens aren't that big, so the result is what I had been shooting for. If I wind up with a working script that doesn't mess with the texture settings, I'll post it to the original thread in the Script Library. Thanks for the Help, both of you. Chris, since I don't need the screen to be a light source, I'll alter the script to make the prim into wood or something instead. Thanks again! Gydeon.
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
06-01-2005 08:20
From: Gydeon Fox Having a problem with this bit, where it's switching to video mode. Whatever's wrong, it's probably wrong on the picture mode as well, but of course I didn't get that far. I'm getting this error line, which places the cursor inside the "llGetTextureScale()" (71, 223) : ERROR : Function call mismatches type or numer of arguments I'm also planning to change "Light" to "Wood" once I get this thing working, since I don't need the screen to be a light source. Gydeon. } //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_LIGHT,PRIM_TEXTURE,DISPLAY_ON_SIDE,video_texture,llGetTextureScale(),llGetTextureOffset(),llGetTextureRot()]); llSetColor(<0,0,0>,0); }
Ack! My bad. I forgot to specify the side to get the texture scale, offset and rotation from, silly me  Here are the corrected two functions: video() //Change mode to Video { llSetObjectDesc("Video mode: 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,"Parcel media texture not 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."); } //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_LIGHT,PRIM_TEXTURE,DISPLAY_ON_SIDE,video_texture,llGetTextureScale(DISPLAY_ON_SIDE),llGetTextureOffset(DISPLAY_ON_SIDE),llGetTextureRot(DISPLAY_ON_SIDE)]); llSetColor(<0,0,0>,0); }
off() { llSetObjectDesc("Touch Screen to Start."); 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_TEXTURE,DISPLAY_ON_SIDE,BLANK,llGetTextureScale(DISPLAY_ON_SIDE),llGetTextureOffset(DISPLAY_ON_SIDE),llGetTextureRot(DISPLAY_ON_SIDE)]); }
And the fully corrected script: //FreeView 1.0 - By CrystalShard Foo //Multifunctional Picture viewer and Video control script //This script is distributed for free and must stay that way. DO NOT SELL THIS SCRIPT UNDER ANY CIRCUMSTANCE.
//Feel free to modify this script and post your improvement. Leave the credits intact but feel free to add your name at its bottom.
//Constants float 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 = "0c40d39e-279c-8f9a-de61-36c99184a612"; //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 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 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
key tempuser; //Temp key storge variable string tempurl; //Temp string storge variable
pictures() //Change mode to Picture Viewer { //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_LIGHT]); llSetColor(<0,0,0>,0); //Initilize variables current_texture = 0; //Set to first texture if available integer check = llGetInventoryNumber(INVENTORY_TEXTURE); if(check > 0) display_texture(check); else { llSetObjectDesc("No pictures found."); llSetTexture(BLANK,DISPLAY_ON_SIDE); } }
video() //Change mode to Video { llSetObjectDesc("Video mode: 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,"Parcel media texture not 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."); } //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_LIGHT,PRIM_TEXTURE,DISPLAY_ON_SIDE,video_texture,llGetTextureScale(DISPLAY_ON_SIDE),llGetTextureOffset(DISPLAY_ON_SIDE),llGetTextureRot(DISPLAY_ON_SIDE)]); llSetColor(<0,0,0>,0); }
off() { llSetObjectDesc("Touch Screen to Start."); 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_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 { string oldurl = llList2String(llParcelMediaQuery([PARCEL_MEDIA_COMMAND_URL]),0); if(oldurl != "") llOwnerSay("Changing Channel. The old channelwas: "+oldurl); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_URL,url]); menu(id); llOwnerSay("Streaming URL set."); }
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"; 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(); }
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),["Set URL","Align ON","Align OFF","Menu"],chan); }
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+=["Back","Next"]; buttons+=["Browse"]; if(loop_image == FALSE) buttons+=["Loop"]; else buttons+=["Unloop"]; buttons+=["Video","Power off"]; } else //Video menu { title+="\n Video display mode"; buttons+=["Configure","Bookmarks","Power off","Pause","Unload","Pictures","Play","Stop","Loop"]; } } else buttons += ["Pictures","Video"]; 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); llSetObjectDesc("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; llSetObjectDesc("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; off(); } 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; //-------------------------------------------------------------------------------
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); llSetObjectDesc("No pictures found."); } } else if(mode == 2) //If video mode if(finditem(NOTECARD) != -1) //And bookmarks notecard present 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(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; llSetObjectDesc("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(mode == 2) { string header = "Video mode: "; 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 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; seturl(message,id); } if(message == "Play") { llSetObjectDesc(header+"Playing"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PLAY]); return; } if(message == "Stop") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_STOP]); return; } if(message == "Pause") { llSetObjectDesc(header+"Paused"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PAUSE]); return; } if(message == "Unload") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_UNLOAD]); return; } if(message == "Loop") { llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_LOOP]); return; } //URL , Auto-Scale, if(message == "Set URL") { llSetObjectDesc(header+"Stopped"); listenurl = llListen(1,"",id,""); // llInstantMessage(llGetOwner(),"Please type the URL of your choice with /1 at the begining. For example, /1 www.google.com"); 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") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_AUTO_ALIGN,TRUE]); menu(id); return; } if(message == "Align OFF") { llSetObjectDesc(header+"Stopped"); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_AUTO_ALIGN,FALSE]); menu(id); return; } } } dataserver(key queryid, string data) { if(queryid == tempuser) //If just checking number of notecard lines { numberofnotecardlines = (integer)data; 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! **"; llDialog(tempuser,"Bookmarks notecard ("+(string)(notecardline+1)+"/"+(string)numberofnotecardlines+")\n"+name+" ("+mediatype(llList2String(llParseString2List(tempurl,["."],[]),-1))+")\n"+tempurl,["<< Prev","Use","Next >>","Menu"],chan); } timer() { if(llGetTime() > listenTimer) //If listener time expired... { llListenRemove(listenHandle); //Remove listeneres. llListenRemove(listenurl); listenHandle = -1; listenurl = -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 } }
|