// This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. // To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/ // or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. // Winter Seale 2008 - winterseale.com string MENU_NAME = "Select a color:"; string MO_BACK = "Back"; list RETURN_MENU = [ "-", "-", MO_BACK ]; list MENU_OPTIONS = [ // Menu Name|Texture Name/UUID/Color "Gray|1a93fa41-85ce-4d64-14a0-c04db47c9d9a", "Greenish|3b76d89b-2d96-796b-fc33-bdacd2df8fa5", "Rose|6d59c124-2327-c423-6c5d-52f8989dda17", "Blue|"+(string)<0,0,1> ]; integer LM_RESET_SECRIPTS = 101; integer LM_SCALE_MESSAGE = 102; integer LM_CAN_COLOR_CHANGE = 103; integer LM_SHOW_COLOR_DIALOG = 104; integer LM_SET_COLOR = 105; integer LM_SHOW_MAIN_DIALOG = 106; integer LM_DEL_SCRIPTS = 200; integer CHANNEL = -114757314; list options_dialog; list options_texture; rebuild_options() { integer count = llGetListLength( MENU_OPTIONS ); integer ii; for ( ii = 0; ii < count ; ii ++ ) { list pieces = llParseString2List( llList2String(MENU_OPTIONS,ii), ["|"], [] ); options_dialog += [ llList2String(pieces,0) ]; options_texture += [ llList2String(pieces,1) ]; } } integer listenhandler; // Rebuild our listener and turn it off. Should really only be done // on owner change. reset_listener() { llListenRemove(listenhandler); listenhandler = llListen( CHANNEL, "", llGetOwner(), ""); llListenControl( listenhandler, FALSE ); } show_dialog() { list menu = RETURN_MENU + options_dialog; llDialog(llGetOwner(), MENU_NAME, menu, CHANNEL); llSetTimerEvent(60); llListenControl( listenhandler, TRUE ); } send_linked(integer command, string options ) { integer dest = LINK_SET; if ( command == LM_CAN_COLOR_CHANGE || command == LM_SHOW_MAIN_DIALOG ) { dest = LINK_THIS; } llMessageLinked( dest, command, options, NULL_KEY ); } default { state_entry() { rebuild_options(); reset_listener(); send_linked(LM_CAN_COLOR_CHANGE,""); } changed(integer mask) { if ( mask & CHANGED_OWNER ) { reset_listener(); } } link_message(integer sender_num, integer command, string message, key id) { if ( command == LM_RESET_SECRIPTS ) { llResetScript(); } else if ( command == LM_SHOW_COLOR_DIALOG ) { show_dialog(); } else if ( command == "LM_DEL_SCRIPTS" ) { llRemoveInventory( llGetScriptName() ); } } listen( integer channel, string name, key id, string message ) { integer sel_index = llListFindList( options_dialog, [message] ); if ( sel_index != -1 ) { send_linked( LM_SET_COLOR, llList2String(options_texture,sel_index) ); show_dialog(); } else if ( message == MO_BACK ) { send_linked( LM_SHOW_MAIN_DIALOG, "" ); } } timer() { llListenControl( listenhandler, FALSE ); llSetTimerEvent(0); } }