Very Simple Dialog Menu Inventory Giver ( V3 )

 

  • Name this script something like "0000000000000000000" (zeros) so that it is definitely the first inventory item listed alphabetically.

Limited script. Not at all advanced. Only 12 inventory items (will update at some point). If giving away scripts, set them to not running.

 

 

// V3 //
 
integer lis;
 
integer channel;
 
integer busy;
 
integer noi;
 
list StrideOfList(list src, integer stride, integer start, integer end)
{
    list l = [];
    integer ll = llGetListLength(src);
    if(start <0)start += ll;
    if(end < 0)end += ll;
    if(end < start) return llList2List(src, start, start);
    while(start <= end)
    {
        l += llList2List(src, start, start);
        start += stride;
    }
    return l;
}
 
default
{
    changed(integer change)
    {
        if(change & CHANGED_INVENTORY)
        llResetScript();
    }
    on_rez(integer param)
    {
        llResetScript();
    }
    state_entry()
    {
        noi = (llGetInventoryNumber(INVENTORY_ALL) - 1);
    }
    touch_start(integer nd)
    {
        if((!busy) && noi)
        {
            busy = TRUE;
            key agent = llDetectedKey(0);
            list stuff = [];
            string name = "";
            integer index = 0;
            while((llGetListLength(stuff) < 24) && (index < 12))
            {
                if((name = llGetInventoryName(INVENTORY_ALL, (++index))) != llGetScriptName())
                {
                    if(name != "")
                    stuff += [(((string)index) + " - " + name), ((string)index)];
                }
            }
            llListenRemove(lis);
            channel = (llRound(llFrand(-10000000)) - 100000);
            lis = llListen(channel, llDetectedName(0), agent, "");
            llDialog(agent, ("\nSelect your inventory offer -\n" +
                            llDumpList2String(StrideOfList(stuff, 2, 0, -1), "\n")), StrideOfList(stuff, 2, 1, -1), channel);
            llSetTimerEvent(30.0);
        }
    }
    listen(integer chan, string name, key id, string msg)
    {
        string item = "";
        if(llGetInventoryType((item = llGetInventoryName(INVENTORY_ALL, ((integer)msg)))) != -1)
        {
            llSetTimerEvent(0.0);
            llListenRemove(lis);
            llGiveInventory(id, item);
            busy = FALSE;
        }
    }
    timer()
    {
        llSetTimerEvent(0.0);
        llListenRemove(lis);
        busy = FALSE;
    }
}
[edit]

 

Basic Dialog Menu

Low Lag menu with brief listen that closes when not in use. Use this simple menu in your own scripts!

 

list MENU_MAIN = ["Hello", "Goodbye"]; //up to 12 in list

integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)
{
    llListenRemove(menu_handler); //BugFix 5/2008
    menu_channel = (integer)(llFrand(99999.0) * -1);
    menu_handler = llListen(menu_channel,"","","");
    llDialog(user,title,buttons,menu_channel);
    llSetTimerEvent(30.0); //how long to wait for user to press a button before giving up and closing listen
}

default
{
    state_entry()
    {
        //nada
    }

    touch_start(integer total_number)
    {
        menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN);
    }
    
    listen(integer channel,string name,key id,string message)
    {
        if (channel == menu_channel) 
        {
            llListenRemove(menu_handler); //close listen
            llSetTimerEvent(0); //stop timeout timer
            if (message == "Hello")
            {
                llSay(0, "World");
            }
            else if (message == "Goodbye")
            {
                llSay(0, "Fine, be that way.");
            }
            //else if (message == "Button")
            //{
                //do something
            //}
        }
    }
    
    timer() //VERY IMPORTANT menu timeout
    {
        llListenRemove(menu_handler); //close listen
        llSetTimerEvent(0); //stop timeout timer
    }
}

 

Dialog Boxes (or Dialogue >.>)

// Bromley College 
// Linden Script Exhibition
 
// Code for poster 36
 
// Note capital letters have been used for some variable names in this script purely for the sake of readability
 
integer CHANNEL = 42; // dialog channel
list MENU_MAIN = ["bow", "flip", "jump"]; // the main menu
string anim;
 
default 
{
    touch_start(integer total_number) //wait for an avatar to touch the poster
    {
        llSay(0, "Respond to the dialog box and then touch the poster again");
        llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION); //ask permission to animate the avatar that touched the poster
        state new; 
    }
}    
 
state new
{        
 
state_entry()     
    {
            llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users 
    }        
 
        touch_start(integer total_number) 
        {
        llDialog(llDetectedKey(0), "What animation do you want your avatar to perform?", MENU_MAIN, CHANNEL); // present dialog on click
    }
 
        listen(integer channel, string name, key id, string message) 
        {
            if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) //if animate permission has been given
            {
                    if (message == "jump")
                        {
                            anim = "jumpforjoy";
                        llStartAnimation(anim);
                            llSay(0,(string)anim);
                               llResetScript();
                    }
 
                    if (message == "flip")
                        {
                            anim = "backflip";
                        llStartAnimation(anim);
                            llSay(0,(string)anim);
                            llResetScript();
                    }
 
                    if (message == "bow")
                    {
                            anim = "courtbow";
                        llStartAnimation(anim);
                            llSay(0,(string)anim);
                            llResetScript();
                         }
                }
 
             if (! (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) //if animate permission has not been given
             {
                     llSay(0, "Agent has not given permission");
                      llResetScript();
            }    
    }     
}                                
 
// End of code;

 

Dialog Button Rearranger

//  Animate on Attach
//  Created by Makaio Stygiann, modified by Water Rogers for IBM/Opensource
 
//  Purpose
//  --------------------------------------------------------------
//  This script shows you how you can order a list of buttons in a
//  dialog box to read from top to bottom, rather then bottom to top
//  like the default.
 
//  Requirements
//  --------------------------------------------------------------
//  A single prim is all that is necessary for this example.
 
//  Usage
//  --------------------------------------------------------------
//  Click on the object to bring up the dialog list.  Click on any of
//  the buttons to flip between ordered, or non-ordered formats.
 
//  GLOBALS
//  --------------------------------------------------------------
list button_list=["1","2","3","4","5","6","7","8","9","10"];    //  list of buttons and their labels
integer dialog_chan=-49324322;                                  //  the channel the dialog talks on
integer g_Rearranged = TRUE;                                    //  rearranger off or on switch
 
//  FUNCTIONS
//  --------------------------------------------------------------
list rearrange(list buttons)
{
    //  This function will return a list of the buttons in the list
    //  so they are in a "Top to Bottom" order, rather then the
    //  "Bottom to Top" order that SL defaults to.
    list reordered=buttons;
    list segment;
    integer total_buttons=llGetListLength(button_list);
    integer rows=total_buttons/3;
    integer remainder=total_buttons%3;
    if(remainder!=0)
    {
        segment=llList2List(reordered,0,remainder - 1);
        reordered=llDeleteSubList(reordered,0,remainder - 1);
        reordered+=segment;
    }
    integer x;
    for(x=0;x