Skip to content

Menu #1

@StarWolff

Description

@StarWolff

// the problem is in the SubMenu_List(key id) function
// This menu worked before I started to add another if/else
// the function was like:
// function()
// some settings
// some stuff
// show dialog box

// I am trying to re-use the function for multiple menus (so it will run this function for one main menu button, which would populate a submenu, run it again for another main menu button, which would populate a second submenu...etc - and I need it to NOT run that function when the main menu is showing

// so I changed the SubMenu_List(key id) function like this:

// function()
// some settings
// if(this is the main menu)
// {
// do some stuff
// }
// else
// {
// some stuff
// }
// show dialog box

// USER SETTABLE PARAMETERS
float MENU_TIMEOUT = 25; // Time in seconds before menu times out & listener is removed

// Menu parameters
integer menu_channel ;
integer options_channel;
integer menu_handler;
integer options_handler;
//list Menu_00 = ["INFO/About","Admin","Close Menu"];
//TEMPORARY MENU
string Menu_00_Caption = "Select a Category";
list Menu_00 = ["INFO/About","Admin","Close Menu","Ground","Horizon","Sky","Sun/Moon","Underground","Themes"];
list Menu_NAV_butt = ["<==","Themes","==>"];
list Menu_THM = ["These","are","dummy","theme","names"," - ","Don't","click","these"];

// !!!!!!!!
// TEMP specifying this - THE ACTUAL CODE WOULD USE THIS
// to flag which type of Items we're listing
integer Menu_Sub_ID = 0;
list Menu_Sub_Names = ["Main Menu","Ground","Horizon","Sky","Sun/Moon","Underground","Themes"];
string Menu_Sub_Caption = "Main Menu";
// CHANGE THIS: When a SubMenu is selected, set this flag

//Misc parameters
string aviname;
integer Item_CountPointer = 0;
integer Item_CountCurrentPos = 0;
integer Item_Total; // number of sounds in the prim's inventory
float sound_volume = 1.0;
string lastsound;

remove_listens()
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
llListenRemove(options_handler);
}

// opens menu channel and displays dialog
SubMenu_List(key id)
{
remove_listens();
menu_channel = -(integer) (llFrand(100000000) + 100000);
options_channel = menu_channel + 1;
menu_handler = llListen(menu_channel, "", NULL_KEY, "");
options_handler = llListen(options_channel,"",NULL_KEY,"");
llSetTimerEvent(MENU_TIMEOUT);

//-SKIP Listing SubMenus~BEG//
// if this is the main menu...
// ------------------------------------------------------------------2FIX this 'if' section
if ((Menu_Sub_Names(Menu_Sub_ID)) == 0)
{
// ...then display the main menu
Menu_Sub_Caption = Menu_00_Caption;
Menu_Sub = Menu_00;
}
// ...and skip the SubMenus Listing
// Otherwise, List SubMenus
else
{

list Menu_Sub = [];
// count the Items in the prim to see if we need pages
Item_Total = llGetInventoryNumber(INVENTORY_TEXTURE);
if (Item_Total < 9)
{
    for (Item_CountPointer = 0; Item_CountPointer < Item_Total; Item_CountPointer++)
    {
        Menu_Sub += llGetInventoryName(INVENTORY_TEXTURE, Item_CountPointer);
    }
    Menu_Sub = Menu_00 + Menu_NAV_butt + Menu_Sub;

}
else
{
    for (Item_CountPointer = 6 * Item_CountCurrentPos; Item_CountPointer < (6 + (6 * Item_CountCurrentPos)) ; Item_CountPointer++)
    {

        // check to make sure name <= 24, or else the menu will not work.
        string Item_Name = llGetInventoryName(INVENTORY_TEXTURE, Item_CountPointer);
        if ( llStringLength(Item_Name) >24)
        {
            llOwnerSay("NOTICE");
            llOwnerSay("Item Name: " + Item_Name + " is too long. Item Names can not be longer than 24 characters");
        }
        else
        {
            if (Item_CountPointer < Item_Total)
            {
                Menu_Sub += Item_Name;
            }
        }
    }
    Menu_Sub = Menu_00 + Menu_NAV_butt + Menu_Sub;
}

// }
Menu_Sub_Caption = "Select a " + llList2String(Menu_Sub_Names, Menu_Sub_ID) + " Item";
llDialog(id, Menu_Sub_Caption, Menu_Sub, menu_channel);

//-SKIP Listing SubMenus~END//
}

}
//---GET SUB LIST END--//

default
{
state_entry()
{

}

on_rez(integer num)
{
    llResetScript();
}

timer()
{
    llSetTimerEvent(0.0);
    remove_listens();
}

touch_start(integer total_number)
{
    aviname = llDetectedName(0);
    Item_CountCurrentPos = 0;
    // display the dialog
    SubMenu_List(llDetectedKey(0));
}

listen(integer channel, string name, key id, string message)
{
    // THIS WILL BE NEEDING TO CHANGE TO A FLAG when you select WHICH menu you're talking to/about
    Menu_Sub_ID = 1;

llSay(0,llList2String(Menu_Sub_Names, Menu_Sub_ID));

    if (channel == menu_channel)
    {
        if (message == "==>")
        {
            if(Item_CountCurrentPos < (llRound((float)Item_Total/6)) ) Item_CountCurrentPos ++;
            SubMenu_List(id);
        }
        else if (message == "<==")
        {
            Item_CountCurrentPos--;
            if (Item_CountCurrentPos < 0) Item_CountCurrentPos = 0;
            SubMenu_List(id);
        }
        else if (message == "Themes")
        {
            llSetTimerEvent(MENU_TIMEOUT);
            Menu_Sub_Caption = "Select a " + llList2String(Menu_Sub_Names, Menu_Sub_ID) + " Item";
            llDialog(id, Menu_Sub_Caption, Menu_THM, options_channel);
        }
        else
        {
            llPlaySound(message, sound_volume);  // Play the sound
            lastsound = message;
            SubMenu_List(id);
        }
    }
    if (channel == options_channel)
    {
        if(message == "Main Menu")  // no entry in options menu for this so it is currently not used
        {
            Item_CountCurrentPos = 0;
            SubMenu_List(id);
        }
        else if(message == "Admin")
        {
            llSetTimerEvent(MENU_TIMEOUT);
            llTextBox(id,"Enter Sound Volume\nMinimum = 0.0\nMaximum = 1.0",options_channel);
        }

        else // sound volume setting
        {
            sound_volume = (float)message;
            if (sound_volume > 1.0) sound_volume = 1.0;
            if (sound_volume < 0.0) sound_volume = 0.0;
            Item_CountCurrentPos =  0;
            SubMenu_List(id);
        }

    }
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions