Jump to content

Need a script to give objects out when prim is touched (like a drinks menu..


Bedlam Ansome
 Share

You are about to reply to a thread that has been inactive for 4486 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

This should do it for you -- both build the menu list and give the drink when one is selected

integer dialog_channel;integer handle;integer i;key user="";list options;string caption ="Please choose a drink";//DilogPlus created by Ugleh Ulrik //Edited by Taff Nouvelle to put the buttons in correct order.list order_buttons(list buttons){    return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) +        llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10);}integer menuindex;DialogPlus(key avatar, string message, list buttons, integer channel, integer CurMenu){    if (llGetListLength(buttons) >11){        list lbut = buttons;        list Nbuttons = [];        if(CurMenu == -1)        {            CurMenu = 0;            menuindex = 0;        }        if((Nbuttons = (llList2List(buttons, (CurMenu * 9), ((CurMenu * 9) + 8)) + ["Back", "Next","Finished"])) == ["Back", "Next","Finished"])            DialogPlus(avatar, message, lbut, channel, menuindex = 0);        else        {            llDialog(avatar, message,  order_buttons(Nbuttons), channel);        }    }else{            llDialog(avatar, message,  order_buttons(buttons+["Finished"]), channel);    }}build_contents_list(){    options =[];    integer max = llGetInventoryNumber(INVENTORY_OBJECT);    while(i<max){        options+=[llGetSubString(llGetInventoryName(INVENTORY_OBJECT,i),0,23)];        //shorten the name if necessary, as dialog buttons can only contain 24 characters        ++i;    }    llOwnerSay("ready");}present_dialog(key k ){    user=k;    llListenRemove(handle);    handle = llListen(dialog_channel,"",user,"");    llSetTimerEvent(20.0);    menuindex=0;    DialogPlus(user,caption,options,dialog_channel,menuindex);}remove_handle(){    llSetTimerEvent(0.0);    llListenRemove(handle);    user="";}default{    state_entry(){        dialog_channel = ((integer)("0x"+llGetSubString((string)llGetKey(),-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;        //very negative number based on the prim's uuid        build_contents_list();    }    changed(integer change){        if(change & CHANGED_INVENTORY){            state waiting;// don't want to be rebuilding the list several times if several items are put in        }    }    touch_start(integer total_number){        key k = llDetectedKey(0);        if(k!=user){            if(user){                llRegionSayTo(k,0,"Sorry, the item is in use by "+llGetDisplayName(user)+"; please try again in a moment");                return;            }            else{                present_dialog(k);            }        }        else{            present_dialog(k);        }    }    listen(integer channel, string name, key id, string msg){        if ("Finished" == msg){            remove_handle();            return;        }        llSetTimerEvent(20.0);        if(msg == "Next")        {            //If they clicked Next it will go to the next dialog window            DialogPlus(user,caption,options,dialog_channel, ++menuindex);            //++menuindex will turn menuindex plus 1, making it give the next page.        }        else if(msg == "Back")        {            //if they clicked back it will go to the last dialog window.            DialogPlus(user,caption,options,dialog_channel, --menuindex);            //--menuindex will turn menuindex minus 1, making it give the previous page.        }        else{            //If they choose anything besides Back/Next it will be in this section            llSay(0,"Your choice was "+ msg);//Example used, change to whatever you wish.            llGiveInventory(user,llGetInventoryName(INVENTORY_OBJECT,llListFindList(options,[msg])));            //need to find the index number of the object this way, in case we had to shorten the name            remove_handle();        }    }    timer(){        remove_handle();    }}state waiting{    state_entry(){        llSetTimerEvent(5.0);    }    changed(integer change)    {        if(change & CHANGED_INVENTORY){            llSetTimerEvent(5.0);        }    }    timer()// not changed contents in the last 5 seconds    {        llSetTimerEvent(0.0);        state default;    }}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4486 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...