Jump to content

Recommended Posts

Posted (edited)

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

Share this post


Link to post
Share on other sites

A listen event cannot "detect" anything.  You may only use llDetectedKey() in touch*, sensor*, and collision* events.

  • Thanks 1

Share this post


Link to post
Share on other sites
10 minutes ago, Rolig Loon said:

A listen event cannot "detect" anything.  You may only use llDetectedKey() in touch*, sensor*, and collision* events.

Hi! Thanks for your answer! So how do i call menu in this case?

Share this post


Link to post
Share on other sites
1 hour ago, Sunbleached said:

So how do i call menu in this case?

Think carefully.  You already know the UUID of the person who sent the message, don't you?

  • Thanks 1

Share this post


Link to post
Share on other sites
38 minutes ago, Rolig Loon said:

Think carefully.  You already know the UUID of the person who sent the message, don't you?

Yes, so if i just remove llDetectedKey() it says "function call mismatches"...

Share this post


Link to post
Share on other sites

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?

  • Like 1

Share this post


Link to post
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)?

Share this post


Link to post
Share on other sites
Posted (edited)
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

Share this post


Link to post
Share on other sites
4 minutes ago, Rolig Loon said:

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

key id

Share this post


Link to post
Share on other sites

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

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...