Who Is Online

1
Online

Saturday, 23 September 2017 04:07

Simple MultiPage Dialog Menu System

From Rolig Loon:

// Simple Multipage Menu  --  Rolig Loon --  August 2013

// The Menu routine in this script will parse your input list (gNames) into menu pages
//    of 12 buttons each, including a forward button and a back button, as appropriate.
//    It generates a page's buttons on demand, so that the list of button labels is
//    never more than 12 items long.
//    It does NOT trim potential menu items to fit the 25-character limit (or the 
//    12-character display limit), nor does it sort buttons or do other fancy things
//    that you are free to add for yourself.


list gNames = ["A","B","C","D","E","F","G",
       "H","I","J","K","L","M","N","O","P","Q",
       "R","S","T","U","V","W","X","Y"];  // Your list of potential menu choices
integer gMenuPosition;  // Index number of the first button on the current page
integer gLsn;   // Dialog Listen Handle

Menu()
{
    integer Last;
    list Buttons;
    integer All = llGetListLength(gNames);
    if(gMenuPosition >= 9)   //This is NOT the first menu page
    {
        Buttons += "    <----";
        if((All - gMenuPosition) > 11)  // This is not the last page
        {
            Buttons += "    ---->";
        }
        else    // This IS the last page
        {
            Last = TRUE;
        }            
    }    
    else if (All > gMenuPosition+9) // This IS the first page
    {
        if((All - gMenuPosition) > 11)  // There are more pages to follow
        {
            Buttons += "    ---->";
        }
        else    // This IS the last page
        {
            Last = TRUE;
        }            
    }
    else    // This is the only menu page
    {
        Last = TRUE;
    }
    if (All > 0)
    {
        integer b;
        integer len = llGetListLength(Buttons);
        // This bizarre test does the important work ......        
        for(b = gMenuPosition + len + Last - 1 ; (len < 12)&&(b < All); ++b)
        {
            Buttons = Buttons + [llList2String(gNames,b)];
            len = llGetListLength(Buttons);
        }
    }
    gLsn = llListen(-12345,"","","");    
    llSetTimerEvent(10.0);
    llDialog(llGetOwner()," \n",Buttons,-12345);
}

default
{
    touch_start(integer num)
    {
        llListenRemove(gLsn);
        gMenuPosition = 0;
        Menu();
    }
    
    listen(integer channel, string name, key id, string msg)
    {
        llListenRemove(gLsn);
        llSetTimerEvent(0.0);
        if (~llSubStringIndex(msg,"---->"))
        {
            gMenuPosition += 10;
            Menu();
        }
        else if (~llSubStringIndex(msg,"<----"))
        {
            gMenuPosition -= 10;
            Menu();
        }
        else
        {
            //Do whatever the selected button directs..... your choice
        }
    }
    
    timer()
    {
        llSetTimerEvent(0.0);
        llListenRemove(gLsn);
    }
}

 

Flash Scratch to SL - Your Scripting Tool

Script ImageNeed to write a LSL script and don't know how to script?  I know I hate trying to get my head around LSLS when I an in a time crunch. So why not give Flash Scratch a try! Its a great tool for learning and scoding your own scripts for Second Life without having to pay someone to do it and without a crash course in LSL

A Huge thanks to John Bennet of ATLAS Institute at University of Colorado and Eric Rosenbaum at MIT for writing Scratch for SL to begin with.

Read more: Flash Scratch to SL - Your Scripting Tool