Menu+Give+Contents+Selection

=Menu Give Contents Selection=

code //Drop this script into an object with up to 22 objects inside. //When anyone Touches they will get a menu with all the objects available. //Button names in menu will be first 10 characters from that item's name. //Objects you are giving away should be Copy/Transfer.

list object_list; list object_list2; key user = NULL_KEY;

composelist {   integer currentobject = 0; integer totalobjects = llGetInventoryNumber(INVENTORY_OBJECT);

if(totalobjects > 0 & totalobjects <= 12) {       object_list = []; do       { object_list = object_list + llGetInventoryName(INVENTORY_OBJECT, currentobject); currentobject++; }       while (currentobject > 0 & currentobject < totalobjects); }

if(totalobjects > 12 & totalobjects <= 22) {       object_list = ["Next Page"]; do       { object_list = object_list + llGetInventoryName(INVENTORY_OBJECT, currentobject); currentobject++; }       while (currentobject > 0 & currentobject < 11);

object_list2 = ["Last Page"]; do       { object_list2 = object_list2 + llGetInventoryName(INVENTORY_OBJECT, currentobject); currentobject++; }       while (currentobject >= 11 & currentobject < totalobjects); }

if(totalobjects > 22) {       llWhisper(0, "You may only have a maximimum of 22 Objects. Please remove any extra ones."); }   if(totalobjects == 0) {       llWhisper(0, "Please add up to 22 Objects to give away. They should be Copy/Transfer."); } }

//The Menu integer menu_handler; integer menu_channel; menu(key user,string title,list object_list) {   menu_channel = (integer)(llFrand(99999.0) * -1); //random channel menu_handler = llListen(menu_channel,"","",""); llDialog(user,title,object_list,menu_channel); llSetTimerEvent(30.0); //menu channel open for 30 seconds }

default {   state_entry {       composelist; //make list from inventory objects }

touch_start(integer total_number) {       user = llDetectedKey(0); menu(user,"\n\nPlease select one below.",object_list); }

listen(integer channel,string name,key id,string message) {       if (channel == menu_channel) {           if(message == "Next Page") {               menu(user,"\n\nPlease select one below.",object_list2); }           else if(message == "Last Page") {               menu(user,"\n\nPlease select one below.",object_list); }           else {               llGiveInventory(user,message); //Give Object llSetTimerEvent(0.0); llListenRemove(menu_handler); }       }    }

timer //Close the Menu Listen or we'll get laggy {       llSetTimerEvent(0.0); llListenRemove(menu_handler); }

changed(integer change) {       if (change & CHANGED_INVENTORY) //inventory has changed {           llSleep(0.5); composelist; //rebuild the list }   } } code