Tattooshop Posted January 12, 2020 Share Posted January 12, 2020 (edited) 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 January 12, 2020 by Tattooshop Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 12, 2020 Share Posted January 12, 2020 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. 1 Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted January 12, 2020 Share Posted January 12, 2020 (edited) 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 January 12, 2020 by Profaitchikenz Haiku 1 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 12, 2020 Share Posted January 12, 2020 21 minutes ago, Profaitchikenz Haiku said: Ah, Rolig, what do I have to do to get the jump on you ? @) 1 3 Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted January 12, 2020 Share Posted January 12, 2020 I thought Vladimir Putin always took his shirt off when demoing manly devices? 1 3 Link to comment Share on other sites More sharing options...
Tattooshop Posted January 13, 2020 Author Share Posted January 13, 2020 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 More sharing options...
Tattooshop Posted January 13, 2020 Author Share Posted January 13, 2020 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 More sharing options...
Profaitchikenz Haiku Posted January 13, 2020 Share Posted January 13, 2020 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. 1 Link to comment Share on other sites More sharing options...
Tap Quentin Posted May 31, 2021 Share Posted May 31, 2021 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 More sharing options...
Rolig Loon Posted May 31, 2021 Share Posted May 31, 2021 That would depend on how you wrote your script. Basically, though, you tell it that if the counter that it's using to identify the current image being displayed is #0, stop advancing automatically. Link to comment Share on other sites More sharing options...
Recommended Posts
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