Jump to content

Turn Shared Media On and Off Script


Deadly Bunny
 Share

You are about to reply to a thread that has been inactive for 1481 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I seen the video http://www.youtube.com/watch?v=Wv20U7rJuwU&feature=youtu.be&t=3m4s and was wondering is it a script where you can set it so you can type in www.google.com and turn it on and off on a prim. For example lets say the cube I use I want to browse the internet then I click it again to turn it off so it will go back to a regular cube until I click the button on. Is it a way to do that without having to goto edit and hitting the +? Is there a script or a way to do that?

Link to comment
Share on other sites

My friend did this

 

default
{
  state_entry()
  {
      llSetPrimMediaParams(0,                            
          [PRIM_MEDIA_AUTO_PLAY,TRUE,                    
           PRIM_MEDIA_CURRENT_URL,"http://google.com",    
           PRIM_MEDIA_HOME_URL,"http://google.com",      
           PRIM_MEDIA_HEIGHT_PIXELS,512,                  
           PRIM_MEDIA_WIDTH_PIXELS,512]);                
  }
  touch_start(integer sdfas)
  {
       llSetTexture("texturecodehere",0);
  }}

 

you click it and it turns on but how do I turn it off? A code for that

  • Like 1
Link to comment
Share on other sites

One problem is: left clicking on a face which has a web page on it is like clicking on the web page. So you either have to richt click and select "touch" from the menu, or click on a face of the prim that has no media.

Having said that, here's one way to turn media on and off.

integer toggle;SetMedia() {    llWhisper(0, "Starting Media On Prim");    llSetPrimMediaParams(0,                                    [PRIM_MEDIA_AUTO_PLAY, TRUE,                            PRIM_MEDIA_CURRENT_URL, "http://google.com",            PRIM_MEDIA_HOME_URL, "http://google.com",              PRIM_MEDIA_HEIGHT_PIXELS, 512,                          PRIM_MEDIA_WIDTH_PIXELS, 512]);                }default {    state_entry() {        SetMedia();    }    touch_start(integer num) {        if (toggle = !toggle) {            llClearPrimMedia(0);        }        else {            SetMedia();        }    }}

 

  • Like 1
Link to comment
Share on other sites

I'm guessing you mean the land group.

Add another parameter set:

PRIM_MEDIA_PERMS_INTERACT, PRIM_MEDIA_PERM_GROUP (or PRIM_MEDIA_PERM_ANYONE).

Also, if trying to avoid extra clicks, the if(toggle = !toggle) doesn't make much sense - The miniscule bytecode savings is not worth the loss of readability alone and it will not work on a first click after compile or reset. That tiny savings is also completely lost and overshadowed by using a user function instead of inline code.

Link to comment
Share on other sites


Erik Verity wrote:

[ ... ]

Also, if trying to avoid extra clicks, the if(toggle = !toggle) doesn't make much sense - The miniscule bytecode savings is not worth the loss of readability alone and it will not work on a first click after compile or reset. That tiny savings is also completely lost and overshadowed by using a user function instead of inline code.

That's purely a matter of personal style, and it's very common.  If the OP wants to be sure that it always works on first click after a script restart ( a trivial problem), all he has to do is declare toggle = TRUE at the top of the script.  :smileywink:

Link to comment
Share on other sites

I just like if(toggle = !toggle) better than:

if (!toggle) {    toggle = TRUE;    // etc.}else {    toggle = FALSE;    // etc.}

Furthermore, in the case of my example script it does work on first touch after a reset..
State_entry() sets the media. First touch on the prim turns it off. Second touch turns it on again, and so forth.

And, yes llClearPrimMedia() works just as well if the object is deeded to the land owning group.

Link to comment
Share on other sites

I didn't even catch it in the state entry - that does solve that problem. I stand corrected there.

ETA: Declaring it TRUE at the top also works, and I can accept it as a style preference also. I saw it discussed in a group chat a few months back and it seemed bytecode savings was the reasoning for it. That's the main reason I would disagree with - if the saving were needed, that wouldn't make enough difference to guarantee anything. (I personally prefer a simple toggle = !toggle one time at the end of the conditions.)

Link to comment
Share on other sites

We've had some good discussions about personal style here over the years.  My own has evolved as I have had a chance to think about other scripters' reasons.  For example, I do not care to adopt Void Singer's (to me) arcane system for naming variables, but I now always use her convention of starting global variable names with a lower case "g" (as in gAvatar or gCount).  It helps me keep track of which variables are accessible outside the local scope.  Also, thanks again to Void, Strife, and others, I prefer to inline things like gON = !gON when I can.  To me, it makes sense to put a toggle switch where it is going to be used to flip the sense of a statement rather than putting it several lines away.  So I will write

llSetLinkColor(link, <1.0,1.0,0.0>*(gON = !gON), ALL_SIDES);

and be able to see at a glance that the prim is meant to flip from black to yellow as gON switches. 

Some bits of personal style strike me as little more than dazzle, meant to make the parlor tricks look trickier.  I can be impressed at the scripter's cleverness, but not enough to use the trick myself.  I'm also not super impressed by style choices that are recommended because they save bytecode or will make my script a nanosecond faster.  Those are nice goals but, quite frankly, they are not high among my everyday priorities. (It helps that I am unencumbered by a professional scripter's sense of what is proper in the workplace.  :smileyvery-happy: )  I write scripts that I want to be able to read and understand two years later.  If they help some other scripter, so much the better.  That criterion trumps all. 

Link to comment
Share on other sites

  • 6 years later...

Pros and cons of reviving a 7 years old thread... but anyway:

The home symbol (as in a browser) , when the media is active.

Alternative, make you own button and use llSetPrimMediaParamswhere, where you define PRIM_MEDIA_HOME_URL

Remember to check returned status values to handle the external web-based media, if errors.

 

Edited by Rachel1206
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1481 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...