CODE
key owner;
key toucher;
integer menu_channel;
integer listenhandler;
list menu_buttons = ["Blue","Green","Red","Cancel"]; //simple color choices, change for your needs
default
{
state_entry()
{
owner = llGetOwner(); //this identifies the owner when the script is reset or the item is rezzed.
}
touch_start(integer total_number)
{
toucher = llDetectedKey(0); //determine if the person who touched is the owner
if(toucher == owner) //if the toucher is the owner, do this stuff
{
menu_channel = (integer)llGetGMTclock() * -2; //this gives you a random channel based on the gmt clock time, helps keep other objects from interfering with your dialog menu.
listenhandler = llListen(menu_channel,"",toucher,""); //sets up the listen for the dialog choices
llDialog(toucher,"What color would you like?",menu_buttons,menu_channel); //actual dialog menu command
}
else //if toucher is not the owner, tell 'em to go away ;o)
{
llInstantMessage(toucher, "I'm sorry, only the owner may use this.");
}
}
changed(integer change) //reset script if owner changes
{
if(change && CHANGED_OWNER)
{
llResetScript();
}
}
listen(integer menu_channel,string name, key toucher,string choice) //tells the script what to do based on the choice made in the dialog menu
{
llListenRemove(listenhandler); // Stop listening on menu_channel
if(choice == "Blue") //These choices must match exactly the buttons in the list menu_buttons...whatever button is pushed, that will be the message sent from the dialog menu
{
llSetColor(<0,0,1>,ALL_SIDES); //sets object color, ALL_SIDES means all the faces will change to this color. the vector (ie "<0,0,1>" is the <r,g,b> value of the color you want to set.
}
else if(choice == "Green")
{
llSetColor(<0,1,0>,ALL_SIDES);
}
else if(choice == "Red")
{
llSetColor(<1,0,0>,ALL_SIDES);
}
else if(choice == "Cancel")
{
llResetScript();
}
}
}
Tried to comment it as much as I could, so it looks kinda nasty,
but it gives the people asking about it lately a good idea where to start on their own
