Jump to content

Need help at texturing a switch :-)


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

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

Recommended Posts

Hello residents of Second Life!

 

I'm searching for a function that allows me to show others the "switch" is clicked, an indicator when you like to call it so.

My switch has a "normal" switch-texture, i saved it and modified it in photoshop and now i want to put it in the same prim (the switch) where the "normal" switch-texture is - and when a user/resident click it (normaly the owner) the "indicated" switch-texture showed temporary for 1 sec or 2 sec's then it go back to the "normal" switch texture?


What is the best function to do that or someone has a script or knows a free lsl wiki script?


Thank you and

br


Magra :matte-motes-grin:

Link to comment
Share on other sites

The best way to do this is create a SINGLE texture with both off and on texture states next to each other.  Then the LSL script can just change the offset of the texture on the prim.  This is the best way to do it because you're not downloading a new texture so it's more efficient for the server and also since it's the same texture, once downloaded, it's complete, there's no change to grey texture while waiting for the alternate script to load.

Link to comment
Share on other sites

default{    on_rez(integer start_param)    {        llSetTexture("texture1", ALL_SIDES);//name of texture in object inventory    }    state_entry()    {            }    touch_start(integer total_number)    {        llSetTexture("texture2", ALL_SIDES);        llSleep(2.0);//pause for 2.0 seconds        llSetTexture("texture1", ALL_SIDES);//name of texture in object inventory    }}

 ADDED: If it linked use this. llSetLinkTexture.

Link to comment
Share on other sites


steph Arnott wrote:

"there's no change to grey texture while waiting for the alternate script to load."

?

When you texture a face via script, if the texture isn't already in the viewer cache, the progressive texture load process begins. While the texture is downloading, the prim face shows the progress, starting with the default grey, then proceeding through progressively higher resolutions until the full texture has loaded. If you use Sassy's scheme of putting both ON and OFF depictions of the switch in the same texture, then the moment the switch rezzes in the scen, both switch states are present, though only one of them is visible. Upon changing the texture offset to reveal the other state, it appears instantaneously.

If you flip textures on the switch's state change rather than change offset for a single composite texture, the first time this is done after initial scene rezzing, you'll see the download progress for the new state's texture. This will only happen the first time, thereafter both textures are displayed instantly as they're both in the cache.

I have a picture frame that cycles through images in the Contents folder. To avoid this gray/progressive load issue, I apply each new picture to a hidden prim face before bringing it to the front. This forces the texture download, but you don't see it happen. When the fading transition is made from the previous to the new picture, both images are fully rezzed.

Link to comment
Share on other sites

There's another way around the gray problem too.  I mention it only in case the OP has already uploaded an "ON" texture and an "OFF" texture and doesn't want to redo them. (EDIT:  Heh... I just recognized that Maddy said this in her last paragraph.  Oh, well, here's the script anyway.....)

default{    state_entry()    {        llSetTexture("texture1", 2);//name of texture in object inventory, Display on "front" face #2        llSetTexture("texture2", 4);//name of texture in object inventory. Display on hidden face #4    }    touch_start(integer total_number)    {        llSetTexture("texture2", 2);        llSetTimerEvent(2.0); // start a 2 second timer    }    timer()    {        llSetTimerEvent(0.0);  //turn the timer off        llSetTexture("texture1", 2);//name of texture in object inventory    }}

 This assumes that the visible face of the OP's switch is face 2  (the +X face).  If the "ON" texture (texture 2) is always displayed but out of view on the opposite face, then a user's graphics card doesn't need to take the time to download it fresh before rendering it.  This is the method most people use if they are making an in-world slide projector, for example.

BTW, I prefer using a timer event instead of llSleep even in a short script like this one. This is a personal style issue, but it has practical implications too.  llSleep suspends the script entirely, making it unresponsive to any influences until the sleep period has ended.  A timer event, on the other hand, is only triggered at the end of the stated period.  Until then, the script can respond to any other activity.  In this particular case it's almost a moot point, because the script isn't expecting any chat messages or changed events anyway.  Still, it's good to get in the habit of using timers instead of llSleep so that you don't fall into that trap when you write more complex scripts.

  • Like 1
Link to comment
Share on other sites


steph Arnott wrote:

default{    on_rez(integer start_param)    {        llSetTexture("texture1", ALL_SIDES);//name of texture in object inventory    }    state_entry()    {            }    touch_start(integer total_number)    {        llSetTexture("texture2", ALL_SIDES);        llSleep(2.0);//pause for 2.0 seconds        llSetTexture("texture1", ALL_SIDES);//name of texture in object inventory    }}

 ADDED: If it linked use this. llSetLinkTexture.

does exactly what i want, texture is gray until its loaded...maybe a way to preload it? but great! :smileyhappy:

Link to comment
Share on other sites

Which is why a single texture with both on it and replace those two llSetTexture statements with llSetPrimitiveParamsFast functions to just change the offset one way and then the other.  No gray.

Also, if you give that item to someone else, then the textures will need to be inside the prim as full permission textures.  You may want to consider using the texture UUID instead of the texture by name.

Link to comment
Share on other sites


Rolig Loon wrote:

There's another way around the gray problem too.  I mention it only in case the OP has already uploaded an "ON" texture and an "OFF" texture and doesn't want to redo them. (EDIT:  Heh... I just recognized that Maddy said this in her last paragraph.  Oh, well, here's the script anyway.....)
default{    state_entry()    {        llSetTexture("texture1", 2);//name of texture in object inventory, Display on "front" face #2        llSetTexture("texture2", 4);//name of texture in object inventory. Display on hidden face #4    }    touch_start(integer total_number)    {        llSetTexture("texture2", 2);        llSetTimerEvent(2.0); // start a 2 second timer    }    timer()    {        llSetTimerEvent(0.0);  //turn the timer off        llSetTexture("texture1", 2);//name of texture in object inventory    }}

 This assumes that the visible face of the OP's switch is face 2  (the +X face).  If the "ON" texture (texture 2) is always displayed but out of view on the opposite face, then a user's graphics card doesn't need to take the time to download it fresh before rendering it.  This is the method most people use if they are making an in-world slide projector, for example.

BTW, I prefer using a
timer
event instead of
llSleep
even in a short script like this one. This is a personal style issue, but it has practical implications too. 
llSleep
suspends the script entirely, making it unresponsive to any influences until the sleep period has ended.  A
timer
event, on the other hand, is only triggered at the
end
of the stated period.  Until then, the script can respond to any other activity.  In this particular case it's almost a moot point, because the script isn't expecting any chat messages or changed events anyway.  Still, it's good to get in the habit of using timers instead of
llSleep
so that you don't fall into that trap when you write more complex scripts.

works as described and that the texture is "preloaded" is nice to have.

ty 4 your describtion about the differences between llSleep and timer.

normaly iam a scripting noob² but u all did that so that i understand it and can learn.

 

GREAT COMM here. TY all :smileyvery-happy:

Link to comment
Share on other sites

i try'd all your solutions and combined, see:

 

default
{
    state_entry()
    {
        llSetTexture("ac6033b4-167a-f977-fd36-b2f72a95d67c", 2);//name of texture in object inventory, Display on "front" face #2
        llOffsetTexture ( -0.25, 0.0, 2);
    }

    touch_start(integer total_number)
    {
        llSetTexture("ac6033b4-167a-f977-fd36-b2f72a95d67c", 2);
        llOffsetTexture ( 0.25, 0.0, 2);
        llSetTimerEvent(0.7); // start a 2 second timer
    }

    timer()
    {
        llSetTimerEvent(0.0);  //turn the timer off
        llSetTexture("ac6033b4-167a-f977-fd36-b2f72a95d67c", 2);//name of texture in object inventory
        llOffsetTexture ( -0.25, 0.0, 2);
    }

}

 

works nice, ty for your help. if any of you had suggestions, my ear is open.

:matte-motes-sunglasses-3:

 

Link to comment
Share on other sites


Drongle McMahon wrote:

I believe different accounts each have their own cache. Someone will confirm or refute.

I don't believe they do, not for textures anyway.  Now, depending on the way they're set up, different viewers will most likely have their caches in different folders, but different accounts usually default to the same folder that is set by that specific viewer.  There may very well be a way to set up your viewer to enable having a different cache for each account, but I've never tried it, simply because doing so would offer no benefit whatsoever.

...Dres

Link to comment
Share on other sites

Yes. In fact there are separate caches for each account (C:\Users\Me\Appdata\Roaming\Secondlife\account\cach\.....), but that's not for textures (a lot of javascript - what on earth is that for?). The textures appear to be in a shared cache (C:\Users\Me\Appdata\Local\Secondlife\texturecache\....). However, if you use different computer accounts for each avatar, then I guess there would be separate texture caches, as the latter is still User specific (no SL stuff under default user's appdata). That's unlikely though. I can see a purpose - if the accounts live in different places, then they would each like to have a different set of textures ready in the cache to avoid grey stuff when they login because the other account overwrote them. Hardly worth it though, because it would also mean a lot of wasteful duplication.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3822 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...