Jump to content

llDialog - Its always something small that sets you in a spiral


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

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

Recommended Posts

Anyone helping me here thank you so very much for your time

So here is my question of the day (Yes it is starting to feel like this any more)

Can I use llDialog to write a note to the prims Desc? If so what is wrong here?

integer gDialogChannel = -1;
integer dialogHandle;

open_menu(key inputKey, string inputString, list inputList)
{
    gDialogChannel = (integer)llFrand(DEBUG_CHANNEL)*-1;
    dialogHandle = llListen(gDialogChannel, "", inputKey, "");
    llDialog(inputKey, inputString, inputList, gDialogChannel);
    llSetTimerEvent(30.0);
}

close_menu()
{
    llSetTimerEvent(0.0);
    llListenRemove(dialogHandle);
}

default
{
    touch_start(integer start_param)
    {
        gDialogChannel = (integer)("0x" + llGetSubString(llGetKey(), 0, 6)) % 2147483647;
        llDialog(llGetOwner(), "Is 2 plus 2?", ["4", "12"], gDialogChannel);
    }

    listen(integer channel, string name, key id, string message)
    {
        if (channel != gDialogChannel)
            return;
        close_menu();
        
        // Check the player's response
        if (message == "4")
        
            // Set the prim description to "4"
            llSetObjectDesc("4");
        
        else if (message == "12")
        {
            // Set the prim description to "12"
             llSetObjectDesc("12");
        }

        close_menu();

        // Register to listen on channel 0624
        llListen(624, "", llGetOwner(), "");
    }

    // Timer event to close the menu
    timer()
    {
        close_menu();
    }
}

I have noticed the IF statement seems to work with or without the {} so I tried it both ways to see if one or the other would work, long story short i left it like that so you could see that i tried it.

Also, I know llSetObjectDesc and llSetPrimitiveParams([PRIM_DESC, "12"]); both can write to the desc however llSetPrimitiveParams does seem to work better for me more often than not. however, neither of them works with llDialog, or at least that seems to be the problem.

Thanks again for your time and efforts

 

Link to comment
Share on other sites

ETA: I see you are not actually calling "open_menu()", but instead you are calling llDialog() directly from touch_start().  That WOULD be fine, except you are not calling llListen()..

So, I think you will find that your listen() event is not firing because you are never calling llListen().  Possibly because you are not calling open_menu() and the code you wrote instead in touch_start() doesn't call llListen()...

=====

Before I saw you are not calling llListen(), here is what I wrote..

I suggest you debug this by adding something like:

llOwnerSay("message="+message); 

..before first checking the value of message.

This way, you are actually checking "what you got back from llDialog()".

In other words:

listen(integer channel, string name, key id, string message)
    {
        if (channel != gDialogChannel)
            return;
        close_menu();
        
// Add a little bit of debugging here..
		llOwnerSay("message="+message);

        // Check the player's response
        if (message == "4")

// rest of your code continues..

FYI, I also noticed that you call close_menu() twice (which obviously is not the issue).

 

Edited by Love Zhaoying
Link to comment
Share on other sites

is as Love says. open_menu is what should be used in touch_start event

touch_start(integer start_param)
{
   // restrict touch to owner
   // when we don't restrict then owner will get the dialog menu
   //   whenever anyone touches
   if (llDetectedKey(0) == llGetOwner())
   {
      open_menu(llGetOwner(), "Is 2 plus 2?", ["4", "12"]);
   }
}

when we want everyone to touch and get the dialog menu then

touch_start(integer start_param)
{
   // allow everyone
   open_menu(llDetectedKey(0), "Is 2 plus 2?", ["4", "12"]);
}

 

Link to comment
Share on other sites

A subtle point, but after making the changes suggested by Love and Elleevelyn, you should also call

llListenRemove(dialogHandle);

at the beginning of your open_menu() function. Otherwise, if the prim is touched 64 times while menu is open (perhaps split across multiple times the menu is opened), the script will accumulate an unclosed listener for each one and crash.

12 hours ago, Shatter Roundel said:
        // Register to listen on channel 0624
        llListen(624, "", llGetOwner(), "");

unclear why this is in the script. channel 624 is never listened to, and this listener is never closed, which again, will crash the script eventually.

 

  • Thanks 1
Link to comment
Share on other sites

For ease of use, I generally prefer llListenControl with a static listener. There are pros and cons to this approach though.

integer gHandleListen;
integer gChannelListen = -17;
key gToucher;

default
{   state_entry()
    {   gHandleListen = llListen(gChannelListen,"","","");
        llListenControl(gHandleListen,FALSE);
    }
    touch_end(integer n)
    {   if(gToucher)
        {   llRegionSayTo(llDetectedKey(0),0,"Menu is in-use.");
        }else
        {   llListenControl(gHandleListen,TRUE);
            llSetTimerEvent(30.0);
            llTextBox(gToucher=llDetectedKey(0),"Please type new description:",gChannelListen);
        }
    }
    timer()
    {   llSetTimerEvent(0);
        gToucher=NULL_KEY;
        llListenControl(gHandleListen,FALSE);
    }
    listen(integer chan, string name, key ID, string text)
    {   llRegionSayTo(gToucher,0,"Setting description to '"+text+"'.");
        llSetObjectDesc(text);
        llSetTimerEvent(0); // alternatively, set to 0.02 to execute listen close procedure.
        gToucher = NULL_KEY;
        llListenControl(gHandleListen,FALSE);
    }
}

 

Edited by Quistess Alpha
forgot a ')' ; probably other mit-steaks.
  • Like 1
Link to comment
Share on other sites

Well, once again you guys saved the day. Thank you all so very much.

It is amazing when you stare at a script long enough that your brain turns into total mush, strange it does not seem to do that when i stare at anything else in the world. Oh well I guess

Just to answer a couple of your questions though I hate being that guy who gets helped and doesn't actually answer the question, in hopes someone else might find this useful

So first thing, the script will not be using the touch event, the only reason it is there was for my sanity while i was testing it. The script is supposed to fire one time ask the question "document" the answer and never use it again. However, in the middle of writing it all and debugging, I realized that maybe I should make it accessible again down the road because the real question is a gender question ... "Do you feel like a... King or Queen?" because I am of a certain age shall we say that to me was initially a straight forward question but then I thought about this day in age I should probably make it do that it could be changed again... cause you just never know.

Long story short I was in the middle of testing thought of it and threw in the llListen event so that I would not forget.. 624 by the way is my birthday, simple placeholder number heheh.

Anyhow so the key to the fix was a combo of the open_menu and debugging to realize where i screwed up. See my little monkey brain said "No wait I put the llListen in the script, I know I did" To which I then proceeded to realize it was a placeholder that had absolutely ZERO to do with what I was actually trying to achieve

 

So anyone who is reading this in the distant future... check your llListen chan and event and for the love of all things DEBUG DEBUG DEBUG is your bestest friend.

Thank  you all once again for your help

 

  • Like 2
Link to comment
Share on other sites

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