Jump to content

Slideshow


Tattooshop
 Share

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

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

Recommended Posts

Hello! is it possible to mod this slideshow script so that you don't have to make a list and it will automatically use textures from the content? And also what is  index here and what for?

Thanks in advance!

list slides =

    ["Texture01", "Texture02", "Texture03", "Texture04"]; /* Textures names list*/

integer index;



newSlide()

{

    string texture = llList2String(slides, index);

    llSetTexture(texture, 1);

    index++;

    if (index >= llGetListLength(slides))

        index = 0;

}



default

{

    state_entry()

    {

        llSetTimerEvent(3);

        index = 0;

        newSlide();

    }



    touch_start(integer num)

    {

        index = 0;

        newSlide();

        llSay(0, "Starting slide show over");

    }



    timer()

    {

        newSlide();

    }

}

 

 

Edited by Tattooshop
Link to comment
Share on other sites

36 minutes ago, Tattooshop said:

is it possible to mod this slideshow script so that you don't have to make a list and it will automatically use textures from the content?

Yes.  

 

37 minutes ago, Tattooshop said:

And also what is  index here and what for?

index is a counter that the script is using to keep track of which slide is the current one being displayed, and to reset to the start of the list when the current slide is the last one.

  • Thanks 1
Link to comment
Share on other sites

Yes, it is possible to modify it, empty the list, then at startup call a small routine that counts how many textures there are in the object and adds each name to the list.

index is the loop counter that chooses the texture from the list. As you can see, it is incremented to get to the next entry in the list and tested so that if it becomes greater than the list it is reset to 0.

// at the top, initialise slides to an empty list

list slides = [];

// then create a function after the line declaring index

getSlides()
{
  integer ii;
  integer iiMax = llGetInventoryNumber(INVENTORY_TEXTURE);
  string name;

    for( ii = 0; ii < iiMax; ii++)
    {
       name = llGetInventoryName(INVENTORY_TEXTURE, ii);
       slides += [name];
    }
}
                            
// then in state_entry , before the line setting the timer event, add this line
                            
    getSlides();
                            
// further enhancements would be to check there are actually some list entries before setting 
// the timer to a non-zero value, and perhaps adding a changed event to re-read the list if 
// the inventory changes (adding or deleting slides)
                            

Ah, Rolig, what do I have to do to get the jump on you ? @)

Edited by Profaitchikenz Haiku
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

12 hours ago, Profaitchikenz Haiku said:

Yes, it is possible to modify it, empty the list, then at startup call a small routine that counts how many textures there are in the object and adds each name to the list.

 

Thank you so much! It works as a dream!

list slides = [];

getSlides()
{
    integer ii;
    integer iiMax = llGetInventoryNumber(INVENTORY_TEXTURE);
    string name;

    for (ii = 0; ii < iiMax; ii++)
    {
        name = llGetInventoryName(INVENTORY_TEXTURE, ii);
        slides += [name];
    }
}

integer index;

newSlide()
{
    string texture = llList2String(slides, index);
    llSetTexture(texture, 1);
    index++;
    if (index >= llGetListLength(slides))
        index = 0;
}

default

{
    state_entry()
    {
        getSlides();
        llSetTimerEvent(3);
        index = 0;
        newSlide();
    }

    /*        touch_start(integer num)
        {
            index = 0;
            newSlide();
            llSay(0,"Starting slide show over");
        }*/

    timer()
    {
        newSlide();
    }
    
    changed(integer change)
    {
        llResetScript();
    }
}

 

Link to comment
Share on other sites

12 hours ago, Profaitchikenz Haiku said:

// further enhancements would be to check there are actually some list entries before setting 
// the timer to a non-zero value
                            

 

This part is very interesting how to do it? Something like

getSlides();

if index !=0

{

llSetTimerEvent(3);

index=0;

newSlide();

}

?

Link to comment
Share on other sites

No, you need to see how many textures you have in the list, to instead of testing index for 0, try llGetListLength(slides) for being greater than 0.

A neat way would be to have a global variable maxSlides, which getSlides sets to be equal to lGetListLength(slides) after it has loaded all he textures, and then all subsequent calls to get the length of the list can be replaced with that variable.

It's not saving much in this particular application, but if you start working on systems that run very rapid loops or do a lot of processing, any reduction in function calls is a bonus.

  • Thanks 1
Link to comment
Share on other sites

  • 1 year later...

Hi... I have a slide show... and it keeps going and going.... If I click on it, it goes back to the beginning ... I am wondering how can I set the script so it when. it reaches slide66 it goes to the beginning and stops... until clicked?

Link to comment
Share on other sites

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