Colour or Color Change With Menu

Written by Kitsune
// when touched, present a dialog with four color choices
 
integer CHANNEL = 42; // dialog channel
list MENU_MAIN = ["red", "blue", "darkblue", "green", "purple", "white", "black", "teal", "...more colors"]; // the main menu
list MENU_OPTIONS = []; // a submenu
 
default {
        state_entry() 
 
        {
                llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users)
        }
        touch_start(integer total_number)
        {
                llDialog(llDetectedKey(0), "What do you want to do?", MENU_MAIN, CHANNEL); // present dialog on click
        }
        listen(integer channel, string name, key id, string message)
        {
                if (llListFindList(MENU_MAIN + MENU_OPTIONS, [message]) != -1)  // verify dialog choice
                {
                        llSay(0, name + " picked the option '" + message + "'."); // output the answer
                        if (message == "...more colors")
                        llDialog(id, "Pick an option!", MENU_OPTIONS, CHANNEL); // present submenu on request
                        else if (message == "...Back")
                        llDialog(id, "What do you want to do?", 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 == "red")
                        llSetColor(<255,255,255>, ALL_SIDES);
                        else if (message == "white")
                        llSetColor(<255,255,255>, ALL_SIDES);
                        else if (message == "black")
                        llSetColor(<0,0,0>, ALL_SIDES);
                        else if (message == "green")
                        llSetColor(<0,125,0>, ALL_SIDES);
                        else if (message == "purple")
                        llSetColor(<127,0,127>, ALL_SIDES);
                        else if (message == "blue")
                        llSetColor(<0,0,255>, ALL_SIDES);
                        else if (message == "darkblue")
                        llSetColor(<0,0,127>, ALL_SIDES);
                        else if (message == "teal")
                        llSetColor(<0,127,127>, ALL_SIDES);
                } else
                llSay(0, name + " picked invalid option '" + llToLower(message) + "'."); // not a valid dialog choice
        }
}