Jump to content
Sunbleached

UUID Automatic Slideshow Script

Recommended Posts

Hello! I want to create a Automatic UUID slideshow script (the UUID is read from the script itself). I have this music player script, which reads music files from UUID list. Does it suit to my project? And what needs to be changed?

integer sounds;
integer count;
list songs=[

// UUID LIST:

"9755f397-79b1-02b0-45ac-afcfbf136de9",
"9040f0d9-681e-fe53-a270-e90e0c7b9526",
"c178eb02-5835-2ad3-ad92-2bcab0c25e14",
"a78fd32e-0179-437b-9a39-6b24916aa433"

];

default {
        touch_start(integer num) {
                llResetTime();
        }
        
        touch_end(integer num) {
                if (llGetTime() > 0.8) llStopSound();
                else llLoopSound(llList2Key(songs, count), 0.5);
                ++count;
                count %=llGetListLength(songs);
        }
}

This is a musical script. when i click, it moves to the next sound. I need to use it for textures and automatically change textures. no clicks.

Does it fit as the start?

Share this post


Link to post
Share on other sites
2 hours ago, Sunbleached said:

Does it fit as the start?

Not really. You might re-use a couple statements that increment count but otherwise it's pretty irrelevant. That's not terribly important, though, because what you want to do with textures is even easier than what's going on here with sounds.

(Incidentally, it's not a great sound script, either. It makes no attempt to pre-load the next sound before it tries to play it, and has a funky way to switch off the sound by touching for more than 0.8 seconds and then releasing the touch which is a very clumsy user interface.)

So, start from scratch. Instead of all this touch_* jazz, you want it to advance automatically, so you'll use a timer() event, and you'll get that started with a llSetTimerEvent() for however long you want between texture changes, probably calling that in state_entry().

Then, in the timer() event itself you'll do the texture-changing, and there are several options for that. If you're changing texture on the scripted item itself, you can use llSetTexture() assigning the count-indexed texture in your list to the side (or "face") you want textured. (Accessing that texture UUID from the list will use llList2Key(), like in the song script.)

If you're instead trying to texture another item in the linkset, rather than the one with the script, you'd use either llSetLinkTexture() or llSetLinkPrimitiveParamsFast(..., [PRIM_TEXTURE, ...]) the latter being useful when there are other object parameters needing changes at the same time.

One object parameter you might want to change at the same time: a hidden, 100% transparent face that pre-caches the next texture so there's no gray, untextured surface while waiting for that texture to download.

And another: In addition to the diffuse texture, you might want to change PRIM_NORMAL and PRIM_SPECULAR if those materials should be defined for the surface you're changing.

  • Thanks 1

Share this post


Link to post
Share on other sites

@Qie Niangao

Thank you so much! Here is what I got now:

integer sounds;
integer count;
list texture=[

// UUID LIST:

"4fedd443-67bd-1a50-bd34-b545320dcb1f",
"3fc1eb82-0b91-71af-fc20-90cbe7400819",
"e9a382d5-bf6d-64b6-ccab-03a8f4148086",
"8b840c69-a483-324a-a8b5-6cfc6e11d2ee"

];

default {
        state_entry() 
        {
                llSetTimerEvent(3);
        }
        
        timer() 
        {
                llSetTexture(llList2Key(texture,count), ALL_SIDES);
                ++count;
                count %=llGetListLength(texture);
        }
}

 

29 minutes ago, Qie Niangao said:

One object parameter you might want to change at the same time: a hidden, 100% transparent face that pre-caches the next texture so there's no gray, untextured surface while waiting for that texture to download.

And another: In addition to the diffuse texture, you might want to change PRIM_NORMAL and PRIM_SPECULAR if those materials should be defined for the surface you're changing.

The part with the preloading option is also very interesting! But how to implement it?
And with the addition of materials I just need to add a separate list?

Share this post


Link to post
Share on other sites

Looks good! (You can lose the sounds global variable that you're not using anymore.)

To preload a texture, you'll use a face of the prim that's hidden. You can make it transparent in the Build Tool if you want. You probably know, but to discover the face number of a surface, use "Select Face" in the Build Tool, select the surface, then Control-Alt-Shift-T. Then, to actually paint that surface with the next texture, you can just replicate the llSetTexture() statement that's first in timer(), changing ALL_SIDES to the one hidden pre-caching face, and putting the new statement last in timer(), after count has already been incremented for the next interval. (This doesn't help with the very first texture change ever, but by the time anybody looks at the object it will have gone through lots of texture changes.)

You're on the right track with using materials, too, using three parallel lists (one for the diffusemap texture, one for normalmap, and one for specularmap). The slightly more advanced way is to use a single "strided" list of [ diffusemap, normalmap, specularmap, next diffusemap, next normalmap, next specularmap... ] and then increment count by 3 instead of 1. That uses a tiny bit less overhead than three lists, but not nearly enough to ever matter. (Strided lists are really only essential when the contents need to be sorted by one of the fields.)

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

Just in passing, I observe that this keeps cycling through the textures forever, and that's often an opportunity to use a very different approach. If the textures are (or can be) low enough resolution that they can all be combined into one higher-resolution image, then you can use llSetTextureAnim() to automatically step through the cels in the texture -- even after the script has been removed from the object. Obviously no script at all demands even less sim resources than this little script. One of the sample textures is 1024x1024, so it couldn't be combined with the others for this trick, but maybe something to keep in mind for the future.

Edited by Qie Niangao
  • Thanks 1

Share this post


Link to post
Share on other sites

Wow! Thank you very much! Did I get it right?

integer count;
list texture=[

// UUID LIST:

"4fedd443-67bd-1a50-bd34-b545320dcb1f",
"3fc1eb82-0b91-71af-fc20-90cbe7400819",
"e9a382d5-bf6d-64b6-ccab-03a8f4148086",
"8b840c69-a483-324a-a8b5-6cfc6e11d2ee"

];

default {
        state_entry() 
        {
                llSetTimerEvent(3);
        }
        
        timer() 
        {
                llSetTexture(llList2Key(texture,count), 0);
                llSetTexture(llList2Key(texture,count), 2);
                ++count;
                count %=llGetListLength(texture);
                
        }
}

Brilliant idea with llSetTextureAnimation() !

Share this post


Link to post
Share on other sites

I had in mind:

timer() 
        {
                llSetTexture(llList2Key(texture,count), 0);
                ++count;
                count %=llGetListLength(texture);
                llSetTexture(llList2Key(texture,count), 2);
                
        }

(assuming the hidden face is 2 and the face to be shown is 0). The idea is that the hidden face can get the next texture, and this way count has been incremented to that next texture just before we paint it on the hidden face.

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

@Qie Niangao Thank you very much again!

Here two versions of the slideshow (applied texture and the texture from the content) using your single texture method. Designed for 2x2 cells (4 combined textures in 1) and played with speed of 1 frame per 2 seconds (0.5 frame per second). And they have on/off toggle.

// Single Texture Slideshow. Applied Texture Version

integer textureIsBeingAnimated;
 
default
{
    touch_start(integer num_detected)
    {
        if (textureIsBeingAnimated)
            llSetTextureAnim(ANIM_ON | LOOP, ALL_SIDES,

//   Edit here...:
        2, // Your texture's frames across - x
        2, // Your texture's frames down - y
        0.0, 

// ...And here:
        4, // Number of all frames
        0.5); // Animation rate 
                            
        else
            llSetTextureAnim(FALSE, ALL_SIDES, 0, 0, 0.0, 0.0, 1.0);     
 
        // toggle back and forth between TRUE (1) and FALSE (0)
        textureIsBeingAnimated = !textureIsBeingAnimated;
    }
}
// Single Texture Slideshow. Content Version

integer textureIsBeingAnimated;
 
default
{
    

    state_entry()
    {
        // the first texture alphabetically inside the same prim's inventory
        string texture = llGetInventoryName(INVENTORY_TEXTURE, 0);
 
        // set it on all sides of the prim containing the script
        llSetTexture(texture, ALL_SIDES);
    }
   
    
    touch_start(integer num_detected)
    {
        if (textureIsBeingAnimated)
            llSetTextureAnim(ANIM_ON | LOOP, ALL_SIDES,

//   Edit here...:
        2, // Your texture's frames across - x
        2, // Your texture's frames down - y
        0.0, 

// ...And here:
        4, // Number of all frames
        0.5); // Animation rate 
                            
        else
            llSetTextureAnim(FALSE, ALL_SIDES, 0, 0, 0.0, 0.0, 1.0);     
 
        // toggle back and forth between TRUE (1) and FALSE (0)
        textureIsBeingAnimated = !textureIsBeingAnimated;
    }
}

 

Edited by Sunbleached
  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)
20 hours ago, Qie Niangao said:

You're on the right track with using materials, too, using three parallel lists (one for the diffusemap texture, one for normalmap, and one for specularmap). The slightly more advanced way is to use a single "strided" list of [ diffusemap, normalmap, specularmap, next diffusemap, next normalmap, next specularmap... ] and then increment count by 3 instead of 1. That uses a tiny bit less overhead than three lists, but not nearly enough to ever matter. (Strided lists are really only essential when the contents need to be sorted by one of the fields.)

I started making a version with materials, but a problem appeared. "Function call mismatches type or number of arguments".

integer count;
vector WHITE=<1.0,1.0,1.0>;

list diffuse=[
"41ece2d9-3b08-71f8-2be1-53326538c4a5",
"c7e79e62-9dd9-016b-2099-f8c4055c1818",
"d66aaefd-2163-0968-742a-b3a0f96127d8"
];

list normal=[
"e346fe7f-6364-9a22-bd56-2d1beed869c8",
"0b372188-80d3-0f92-01c0-c25e9bd13f23",
"084f2b72-5c57-fa12-c6cc-9533d5fe7a87"
];

list specular=[
"824d3e69-4e15-addf-6e28-5b9248fb98fb",
"b0109ad6-8223-c69b-cbb4-df955a8e87e2",
"1db2d0a5-5f3c-56bf-5b3c-7b7c1418a312"
];

default {
        state_entry() 
        {
                llSetTimerEvent(3);
        }
        
        timer() 
        {
                llSetPrimitiveParams(
                
// PROBLEM STARTS HERE:                
PRIM_TEXTURE,2,(llList2Key(diffuse,count)),<1,1,0>,ZERO_VECTOR,0.0,
PRIM_NORMAL,2,(llList2Key(normal,count)),<1,1,0>,ZERO_VECTOR,0.0,    
PRIM_SPECULAR,2,(llList2Key(specular,count)),<1,1,0>,ZERO_VECTOR,0.0,WHITE,100,5        // shown        
                
                
                
                );// shown
                ++count;
                count %=llGetListLength(diffuse);
                llSetTexture(llList2Key(diffuse,count), 0);// hidden
                
        }
}

What could it be?

Edited by Sunbleached

Share this post


Link to post
Share on other sites

Ah. llSetPrimitiveParams() and related functions want all those parameters to be in a list, so you need to put square brackets around the whole list, a la

llSetPrimitiveParams(
	[ PRIM_TEXTURE,2,(llList2Key(diffuse,count)),<1,1,0>,ZERO_VECTOR,0.0
	, PRIM_NORMAL,2,(llList2Key(normal,count)),<1,1,0>,ZERO_VECTOR,0.0
	, PRIM_SPECULAR,2,(llList2Key(specular,count)),<1,1,0>,ZERO_VECTOR,0.0,WHITE,100,5
    ]);

(This is a general truth about LSL functions: they have fixed numbers of arguments, so to get an expandable set of parameters they must be grouped into a list to make a single argument to the function.)

I haven't actually tried the code, but this should get past that particular syntax problem.

  • Thanks 1

Share this post


Link to post
Share on other sites
40 minutes ago, Qie Niangao said:

Ah. llSetPrimitiveParams() and related functions want all those parameters to be in a list, so you need to put square brackets around the whole list, a la


llSetPrimitiveParams(
	[ PRIM_TEXTURE,2,(llList2Key(diffuse,count)),<1,1,0>,ZERO_VECTOR,0.0
	, PRIM_NORMAL,2,(llList2Key(normal,count)),<1,1,0>,ZERO_VECTOR,0.0
	, PRIM_SPECULAR,2,(llList2Key(specular,count)),<1,1,0>,ZERO_VECTOR,0.0,WHITE,100,5
    ]);

(This is a general truth about LSL functions: they have fixed numbers of arguments, so to get an expandable set of parameters they must be grouped into a list to make a single argument to the function.)

I haven't actually tried the code, but this should get past that particular syntax problem.

Perfect! Amazing! It works like magic! Here is what I got. Thank you very much!

integer count;
vector WHITE=<1.0,1.0,1.0>;

list diffuse=[
"41ece2d9-3b08-71f8-2be1-53326538c4a5",
"c7e79e62-9dd9-016b-2099-f8c4055c1818",
"d66aaefd-2163-0968-742a-b3a0f96127d8"
];

list normal=[
"e346fe7f-6364-9a22-bd56-2d1beed869c8",
"0b372188-80d3-0f92-01c0-c25e9bd13f23",
"084f2b72-5c57-fa12-c6cc-9533d5fe7a87"
];

list specular=[
"824d3e69-4e15-addf-6e28-5b9248fb98fb",
"b0109ad6-8223-c69b-cbb4-df955a8e87e2",
"1db2d0a5-5f3c-56bf-5b3c-7b7c1418a312"
];

default {
        state_entry() 
        {
                llSetTimerEvent(3);
        }
        
        timer() 
        {
                
                
               
llSetPrimitiveParams(
    [ PRIM_TEXTURE,2,(llList2Key(diffuse,count)),<1,1,0>,ZERO_VECTOR,0.0
    , PRIM_NORMAL,2,(llList2Key(normal,count)),<1,1,0>,ZERO_VECTOR,0.0
    , PRIM_SPECULAR,2,(llList2Key(specular,count)),<1,1,0>,ZERO_VECTOR,0.0,WHITE,100,5
    ]);         // shown    

                
  
                ++count;
                count %=llGetListLength(diffuse);
                count %=llGetListLength(normal);
                count %=llGetListLength(specular);
llSetPrimitiveParams(
    [ PRIM_TEXTURE,0,(llList2Key(diffuse,count)),<1,1,0>,ZERO_VECTOR,0.0
    , PRIM_NORMAL,0,(llList2Key(normal,count)),<1,1,0>,ZERO_VECTOR,0.0
    , PRIM_SPECULAR,0,(llList2Key(specular,count)),<1,1,0>,ZERO_VECTOR,0.0,WHITE,100,5
    ]);         // hidden
                
        }
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...