dialog_plus.lsl

This is the source code of an included piece of LSL that I use frequently. It implements simple back and next buttons to select from more that 12 options in a dialog.

If you don’t use (or want to use) the Firestorm preprocessor, copy the code between the hash directives and replace the #include that led you to this page with the code you find here (that’s essentially what the preprocessor does for you automatically).

#ifndef __DIALOG_PLUS
#define __DIALOG_PLUS

//Created by Ugleh Ulrik
//This sort of script should cost, but for you free :)
//Edited by Taff Nouvelle to put the buttons in correct order.
//Edited by BluesToday Resident to conform to 1TBS and variable naming for globals
 
list order_buttons (list buttons) {
    return llList2List (buttons, -3, -1) + llList2List (buttons, -6, -4) +
        llList2List (buttons, -9, -7) + llList2List (buttons, -12, -10);
}
 
integer g_menu_idx;

DialogPlus (key avatar, string message, list buttons, integer channel, integer CurMenu) {
    if (12 < llGetListLength (buttons)) {
        list lbut = buttons;
        list Nbuttons = [];
        if (CurMenu == -1) {
            CurMenu = 0;
            g_menu_idx = 0;
        }
 
        if ((Nbuttons = (llList2List (buttons, (CurMenu * 10), ((CurMenu * 10) + 9)) + ["Back", "Next"])) == ["Back", "Next"]) {
            DialogPlus (avatar, message, lbut, channel, g_menu_idx = 0);
        } else {
            llDialog (avatar, message,  order_buttons (Nbuttons), channel);
        }
    } else {
        llDialog (avatar, message,  order_buttons (buttons), channel);
    }
}

#endif // __DIALOG_PLUS