Jump to content

Help with a slideshow


Laufiair Hexicola
 Share

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

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

Recommended Posts

Morning everyone, I'm usually competent enough to figure out most scripting on my own but this one has me scratching my head. I took a slideshow script and added it to a menu so I could decide what list to use only for some reason it doesn't. If I choose halloween, it'll slide through the images then revert to images for general, not reslide the halloween images. I've played with index numbers, renaming the slides, putting the clauses itself in the button action... nothing seems to correct it so I figured I'd call out to others for a second look, see what I'm missing.

Thanks in advance, Logan

The script i'm using:

list general = ["ec73e727-a351-c10f-924c-47f9c8a2a733", "26f73387-08fa-f712-60ac-02aa4e953571"];
list hween = ["bd24a835-db24-f6ff-1ef3-1c9c14b9ea38", "cddcce41-2f24-ebb6-0337-503572751714"];
integer index;


string mainMenuDialog = "\nCommission Menu, choose a theme to display.";
list mainMenuButtons = ["General", "Halloween", "Close"];
 
integer dialogChannel;
integer dialogHandle;
 
open_menu(key inputKey, string inputString, list inputList)
{
    dialogChannel = (integer)llFrand(DEBUG_CHANNEL)*-1;
    dialogHandle = llListen(dialogChannel, "", inputKey, "");
    llDialog(inputKey, inputString, inputList, dialogChannel);
    llSetTimerEvent(30.0);
}
 
close_menu()
{
    llSetTimerEvent(0);
    llListenRemove(dialogHandle);
}

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

newSlide2()
{
    string texture2 = llList2String(hween,1);
    llSetTexture(texture2,1);
    index++;
    if(1>=llGetListLength(hween) )
    index = 0;
}




default
{
    on_rez(integer start_param)
    {
        llResetScript();
    }
 
    touch_start(integer total_number)
    {
        key id = llDetectedKey(0);
        close_menu();
        open_menu(id, mainMenuDialog, mainMenuButtons);
    }
 
    listen(integer channel, string name, key id, string message)
    {
        if(channel != dialogChannel)
            return;
 
        close_menu();
 
        if(message == "General")
        {
            llSetTimerEvent(10);
            index = 0;
            newSlide();
        }
 
        else if(message == "Halloween")
        {
            llSetTimerEvent(10);
            index = 0;
            newSlide2();
        }     
    }
 
    timer()
    {
        close_menu();
        newSlide();
        newSlide2();
    }
}

 

Link to comment
Share on other sites

There are a number of issues with the script which I think can be summarized into two general categories.

  • Your timer event has no logic inside it to facilitate deciding which helper function to call. Instead it just blindly calls close_menu, newSlide, and newSlide2 all at once every time. These functions directly conflict with each other.
  • There are a lot of hard-coded values in the code which not only makes the script inflexible, but actively works against the intended function. Especially since you have an index variable, but are not using it at all.

You're using your timer event for two different things: closing out the listener and also advancing the frame. However, the close_menu function calls llSetTimerEvent(0) which halts any active timers. This is problematic since it will stop your slideshow from advancing beyond the first frame. Additionally, since you are calling newSlide AND newSlide2, your script is incapable of sticking to one set of frames. When the user selects one of the options, it will display the correct first frame. But after that, when the timer pops, your script as currently written will always:

  1. call close_menu, which kills any active timer.
  2. call newSlide which sets the texture of face 1 to be the first texture from the General set
  3. call newSlide2 which sets the texture of face 1 to be the second texture from the Haloween set.

So to start, I would get rid of the newSlide2 function entirely. Instead, just use the original newSlide function and update it to be flexible enough to operate on whatever the current set is. One way to do this is to create a new global list variable called "currentList". In your listen event, when you discover which option the user selected, update this variable with a copy of the approriate list. For example, if the message was "Halloween", set currentList=hween; Or if the message was "General" set currentList=general;

Then, in your newSlide function, reference the currentList instead of the general or hween lists. The point is to use a variable instead of a hard-coded value. Similarly, you never actually use the index variable when picking list elements to set the current texture to. Use that instead of the hard-coded 0. This is also the case for the out of bounds checking you do to reset index to 0 if it's greater than or equal to the list length.

As for the Timer event, remove the call to close_menu - or at least remove the llSetTimerEvent(0) from that function. There are better ways to handle this, but for now try the above.

  • Like 1
Link to comment
Share on other sites

while very oldskool, I fixed it using a script called menu that tells the other scripts general and halloween to turn on or off using llSetScriptState. To be honest I was not able to figure out how to set global variables so when I click the menu button for the theme it goes to that list. The script and display is for myself to control so I don't mind it being this way. When my fox mind stops being derpy long enough i'll probably return here to everything is one script but it works for now so i'm ok with it.

Thanks Fenix for your input,

Logan

Link to comment
Share on other sites

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