Jump to content

Menu by chat command


Sunbleached
 Share

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

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

Recommended Posts

Hello! I am trying to make light script with the menu so that it activates on the chat command, but something does not work. where I was wrong, tell me please!

vector LIGHT_COLOR = < 1.0, 1.0, 1.0 > ; //Light color
integer LIGHT_PRIM = LINK_THIS; //LINK_SET or prim number
integer LIGHT_FACE = 0; //light face <<<<<<<<<<<

list MENU_MAIN = ["MIN","MID","MAX","ON","OFF","DELETE"]; 

integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)
{
    llListen(10,"","","");
    llListenRemove(menu_handler); 
    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()
    {
        llListen(10,"","","");
    }
    listen(integer channel,string name,key id,string msg)
    {
    if(msg=="glow")

    {
        menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN);
    }

    

        if (channel == menu_channel) 
        {
            llListenRemove(menu_handler); //close listen
            llSetTimerEvent(0); //stop timeout timer
            if (msg == "MIN")
            {
            llSay(0, "Min Light");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 0.25,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 0.25 // START INTENSITY
            , 5.0 // START RADIUS
            , 1.0 // START FALLOFF
            ]);
                
            }
            else if (msg == "MID")
            {
            llSay(0, "Mid Light");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 0.50,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 0.5 // START INTENSITY
            , 10.0 // START RADIUS
            , 0.5 // START FALLOFF
            ]);
            }
            else if (msg == "MAX")
            {
            llSay(0, "Max Light");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 1.00,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 1.0 // START INTENSITY
            , 20.0 // START RADIUS
            , 0.0 // START FALLOFF
            ]);
            }
            else if (msg == "ON")
            {
            llSay(0, "Light is ON");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 1.00,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 1.0 // START INTENSITY
            , 20.0 // START RADIUS
            , 0.0 // START FALLOFF
            ]);
            }
            else if (msg == "OFF")
            {
            llSay(0, "Light is OFF");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, ALL_SIDES, FALSE, PRIM_POINT_LIGHT, FALSE,
            ZERO_VECTOR // COLOR
            , 0.0 // INTENSITY
            , 0.0 // RADIUS
            , 2.0 // FALLOFF
            ]);
            }
            else if (msg == "DELETE")
            {
            llSay(0, "Script Deleted");
            llRemoveInventory(llGetScriptName());
            }
            //else if (msg == "Button")
            //{
                //do something
            //}

    }}
    
    timer() //VERY IMPORTANT menu timeout
    {
        llListenRemove(menu_handler); //close listen
        llSetTimerEvent(0); //stop timeout timer
    }
}

 

Edited by Sunbleached
Link to comment
Share on other sites

4 minutes ago, Rolig Loon said:

Yes, so don't do that.  I'm not going to tell you the answer.  This is one you can figure out easily if you stop and think about it.  Where do you already know who sent the message?

menu(key user,string title,list buttons)?

Link to comment
Share on other sites

11 minutes ago, Sunbleached said:

menu(key user,string title,list buttons)?

No, that's the routine that you are sending the information.  When you are receiving the message in the listen event, how do you know who sent it?

Edited by Rolig Loon
  • Thanks 1
Link to comment
Share on other sites

20 minutes ago, Rolig Loon said:

Bingo.  Now see what happens.  Trust your ability to solve a problem like this.  You can usually do it.  😎

menu(llGetOwnerKey(id), "\nText for Menu.", MENU_MAIN);

Thank you! it works now!

Edited by Sunbleached
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1699 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...