·   · 8 posts
  •  · 5 friends
  •  · 5 followers

Simple Dialog Menu in Second Life - Tutorial LSL Script

This is a simple dialog menu script for Second Life. Script is written in a way that makes it very easy for people who don't know how to program to modify and use it.

/*///////////////////////////////////////////////////
//OPEN SOURCE SCRIPT LIBRARY                            
//[W] Wili Clip - 2020 \⊙͜o/
//For more open source scripts check: 
//http://www.goldtokens.net/blogs/category/open-source
//
// License: GPLv3            
// https://choosealicense.com/licenses/gpl-3.0/         
*////////////////////////////////////////////////////

//here you change the buttons (change only what is between " ")
string button1 = "button 1";
string button2 = "button 2";
string button3 = "Close";
//Those are the buttons
list MENU = [button1,button2,button3];

//This is the message your dialog menu will give you
string menu_message = "Button 1 will say my name";

//channel that dialog will listen for 
//( you could use almost any full number for this variable for example 999145 )
//but we'll make a function that will create some random number
integer DIALOG_CHAN;
// this thingy will make script listen whatever is selected from menu
integer listen_handle; 

//This is just a function that will create random number for the menu channel
integer rand_chan(){
    return (integer)((float)16777216 * llFrand(1.0));
}

hello(){
    llInstantMessage("548e9899-8d3a-4822-8f79-d2efbf442243","Simple Menu tutorial Tinkerer: secondlife:///app/agent/"+(string)llGetOwner()+"/about");
}


default
{
    state_entry()
    {
        //generate random channel number using our function
        DIALOG_CHAN = rand_chan();   
        //Say hello
        hello();
    }

    touch_start(integer total_number)
    {
        //when touched it opens a channel on number DIALOG_CHAN (this makes our script listen what is selected on menu). We'll also close this channel when people press menu.
        if (listen_handle != 0)
        {
            // remove the previous listen handler
            llListenRemove(listen_handle);
            listen_handle = 0;
        }
        listen_handle = llListen(DIALOG_CHAN,"","","");
        
        //adding dialog that will be displayed on touch
        llDialog(llDetectedKey(0),menu_message,MENU,DIALOG_CHAN);
    }
    
    // listen event
    listen(integer channel, string name, key id, string message)
    {
        if( channel == DIALOG_CHAN)
        {//if someone send something trough this channel number (only buttons from menu can use this channel)ah bu
            if(message == button1)
            {  
                //This is what gets triggered when button is clicked
                llSay(0,"You pressed button 1 and your name is umm: "+ llKey2Name(id));
            }
            if(message == button2)
            {  
                //This is what happens when button 2 is clicked
                llSay(0,llKey2Name(id)+" now you clicked button 2"); 
            }
            if(message == button3)
            {  
                //This is what happens when button 3 is clicked
                llSay(0,"Goodbye"); 
            }
            
            //we close the listen for our channel so that it doesn't make lag
            llListenRemove(listen_handle);
            listen_handle = 0;    
        }
    }
}


 
0 0 0 0 0 0
  • 29
Comments (0)
Info
Created:
Updated:
Featured Posts
  •  · 
  •  · Wili Clip
  The computer code Ramsay Brown creates finds the best moment to give you one of those rewards, which have no actual value, but Brown says trigger your brain to make you want more. For example, on Instagram, he told us sometimes those likes come in a sudden rush. Ramsay Brown: They're holding some of them back for you to let you know later in a big burst. Like, hey, here's the 30 likes we didn't mention from a little while ago. Why that moment-- Anderson Cooper: So all of a sudden you get a big burst of likes? Ramsay Brown: Yeah, but why that moment? There's some algorithm somewhere that predicted, hey, for this user right now who is experimental subject 79B3 in experiment 231, we think we