Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Creating catagories via notecard

beat Kotobide
Registered User
Join date: 12 Oct 2006
Posts: 3
03-04-2007 16:02
As of now, I am utilizing the blue, drop-down, HUD. The categories are within the script. However, I would like to be able to add and subtract categories (and sub-categories) by simply typing or deleting from a notepad. Is this possible?

// when HUD touched, present a dialog with four color choices

integer CHANNEL = 808; // dialog channel
list MENU_MAIN = ["A", "B", "C", "D", "E"]; // the main menu
list MENU_A = ["0", "1", "2", "3", "4", "5", "Back"]; // a submenu
list MENU_B = ["0", "1", "2", "3", "4", "5", "Back"]; // a submenu
list MENU_C = ["0", "1", "2", "3", "4", "5", "Back"]; // a submenu
list MENU_D = ["0", "1", "2", "3", "4", "5", "Back"]; // a submenu
list MENU_E = ["0", "1", "2", "3", "4", "5", "Back"]; // a submenu
default {
state_entry()
{
llListen(CHANNEL, "", NULL_KEY, "";); // listen for dialog answers (from multiple users)

}

touch_start(integer total_number)
{
llDialog(llDetectedKey(0), "WALLPAPER MENU", MENU_MAIN, CHANNEL); // present dialog on click
}


listen(integer channel, string name, key id, string message)
{
string response_string;

if (llListFindList(MENU_MAIN + MENU_A, [message]) != -1) // verify dialog choice
{
if (message == "A";)
llDialog(id, "SELECT A WALLPAPER", MENU_A, CHANNEL); // present submenu on request
if (message == "0";)
llShout( 808, "0" ) ;
if (message == "1";)
llShout( 808, "1" ) ;
if (message == "2";)
llShout( 808, "2" ) ;
if (message == "3";)
llShout( 808, "3" ) ;
if (message == "4";)
llShout( 808, "4" ) ;
if (message == "5";)
llShout( 808, "5" ) ;
else if (message == "Back";)
llDialog(id, "WALLPAPER MENU", MENU_MAIN, CHANNEL); // present main menu on request to go back
// here you have the name and key of the user and can easily verify if they have the permission to use that option or not
if (message == "B";)
llDialog(id, "SELECT A WALLPAPER", MENU_B, CHANNEL); // present submenu on request
if (message == "0";)
llShout( 808, "0" ) ;
if (message == "1";)
llShout( 808, "1" ) ;
if (message == "2";)
llShout( 808, "2" ) ;
if (message == "3";)
llShout( 808, "3" ) ;
if (message == "4";)
llShout( 808, "4" ) ;
if (message == "5";)
llShout( 808, "5" ) ;
else if (message == "Back";)
llDialog(id, "WALLPAPER MENU", MENU_MAIN, CHANNEL); // present main menu on request to go back
// here you have the name and key of the user and can easily verify if they have the permission to use that option or not
else if (message == "C";)
llDialog(id, "SELECT A WALLPAPER", MENU_C, CHANNEL); // present submenu on request
if (message == "0";)
llShout( 808, "0" ) ;
if (message == "1";)
llShout( 808, "1" ) ;
if (message == "2";)
llShout( 808, "2" ) ;
if (message == "3";)
llShout( 808, "3" ) ;
if (message == "4";)
llShout( 808, "4" ) ;
if (message == "5";)
llShout( 808, "5" ) ;
else if (message == "Back";)
llDialog(id, "WALLPAPER MENU", MENU_MAIN, CHANNEL); // present main menu on request to go back
// here you have the name and key of the user and can easily verify if they have the permission to use that option or not
else if (message == "D";)
llDialog(id, "SELECT A WALLPAPER", MENU_D, CHANNEL); // present submenu on request
if (message == "0";)
llShout( 808, "0" ) ;
if (message == "1";)
llShout( 808, "1" ) ;
if (message == "2";)
llShout( 808, "2" ) ;
if (message == "3";)
llShout( 808, "3" ) ;
if (message == "4";)
llShout( 808, "4" ) ;
if (message == "5";)
llShout( 808, "5" ) ;
else if (message == "Back";)
llDialog(id, "WALLPAPER MENU", MENU_MAIN, CHANNEL); // present main menu on request to go back
// here you have the name and key of the user and can easily verify if they have the permission to use that option or not
else if (message == "E";)
llDialog(id, "SELECT A WALLPAPER", MENU_E, CHANNEL); // present submenu on request
if (message == "0";)
llShout( 808, "0" ) ;
if (message == "1";)
llShout( 808, "1" ) ;
if (message == "2";)
llShout( 808, "2" ) ;
if (message == "3";)
llShout( 808, "3" ) ;
if (message == "4";)
llShout( 808, "4" ) ;
if (message == "5";)
llShout( 808, "5" ) ;
else if (message == "Back";)
llDialog(id, "WALLPAPER MENU", MENU_MAIN, CHANNEL); // present main menu on request to go back
// here you have the name and key of the user and can easily verify if they have the permission to use that option or not
}
else
{
//llSay(0, name + " picked invalid option '" + llToLower(message) + "'.";); // not a valid dialog choice
response_string = name + " picked invalid option '" + llToLower(message) + "'.\n";
response_string = response_string + "Click HUD for dialog of options";
}


}
}
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
03-05-2007 00:10
notecards are rom (read only memory) and your if tree makes me weep
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-05-2007 02:00
From: Osgeld Barmy
notecards are rom (read only memory) and your if tree makes me weep



*Hands Osgeld a big box of tissues*
There there, its ok, they all learn eventually....

Your huge IF tree is also almost completely superflous as you are repeating the same checks for each sub menu but have no way of differentiating which sub menu its from as they all contain the extact same data.

You are also shouting on the same channel as you are using for your dialog, is this intentional?

CODE

// when HUD touched, present a dialog with four color choices

list MENU_MAIN = ["A", "B", "C", "D", "E"]; // the main menu
list MENU_A = ["0", "1", "2", "3", "4", "5", "Back"]; // a submenu
list MENU_B = ["0", "1", "2", "3", "4", "5", "Back"]; // a submenu
list MENU_C = ["0", "1", "2", "3", "4", "5", "Back"]; // a submenu
list MENU_D = ["0", "1", "2", "3", "4", "5", "Back"]; // a submenu
list MENU_E = ["0", "1", "2", "3", "4", "5", "Back"]; // a submenu


integer Listening = 0;
integer DialogChannel = 0; // dialog channel
integer CHANNEL = 808; // dialog channel

// --------------------------
UpdateListen(key id)
{
CancelListen();
DialogChannel = 0 - (integer)llFrand(2147483647);
Listening = llListen(DialogChannel,"",id,"");
llSetTimerEvent(20);
}
// --------------------------
CancelListen()
{
if(Listening > 0) llListenRemove(Listening);
Listening = 0;
llSetTimerEvent(0);
}
// --------------------------

default
{
state_entry()
{
CancelListen();
}

touch_start(integer total_number)
{
key id = llDetectedKey(0);
UpdateListen(id);
llDialog(id, "WALLPAPER MENU", MENU_MAIN, DialogChannel ); // present dialog on click
}


listen(integer channel, string name, key id, string message)
{
CancelListen();
integer index = llListFindList(MENU_MAIN, [message]);
if(index >= 0)
{
if(0 == index) llDialog(id, "SELECT A WALLPAPER", MENU_A, DialogChannel ); // menu A
else if(1 == index) llDialog(id, "SELECT B WALLPAPER", MENU_B, DialogChannel ); // menu B
else if(2 == index) llDialog(id, "SELECT C WALLPAPER", MENU_C, DialogChannel ); // menu C
else if(3 == index) llDialog(id, "SELECT D WALLPAPER", MENU_D, DialogChannel ); // menu D
else if(4 == index) llDialog(id, "SELECT E WALLPAPER", MENU_E, DialogChannel ); // menu E
}
else if (message == "Back")
{
llDialog(id, "WALLPAPER MENU", MENU_MAIN, DialogChannel ); // present main menu on request to go back
}
else // Everything else is just shouted on thsi channel
{
llShout( CHANNEL, message ) ;
}
}

timer()
{
CancelListen();
}
}


Now as for adding notecard support, look at this thread
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
03-05-2007 02:51
From: Osgeld Barmy
...and your if tree makes me weep

LOL! But you see that so many times... fortunately Newg was there to save the day again :)
_____________________
http://slurl.com/secondlife/Together
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
03-05-2007 16:15
i know its bad form for me to complain about something then not show what i mean,... but i relised it was 3am, thx Newgate
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-06-2007 01:27
May be we need to add a section on the correct use of IF to the sticky ? :D
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
03-06-2007 17:49
sounds like a good idea
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-10-2007 04:47
From: Osgeld Barmy
sounds like a good idea


Added