Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

help needed about dialog menu

Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
11-01-2008 00:21
Well, below script works fine but I need my dialog menu keep appearing after next or prev buttons clicked. Anyone with an idea ?

here is the script ;

From: someone

key id;
string mess = "demo";
list menu = ["<< PREV","CANCEL","NEXT >>"];
integer chan;
integer h;
//=======================================================
init()
{
llListenRemove(h);
key id;
h = llListen(chan, "",id, "";);
}
//======================================================
dialog()
{
id = llDetectedKey(0);
chan = llFloor(llFrand(100000.0)) + 1000;
init();
llDialog(id,mess,menu,chan);
}
//=====================================================
default
{
state_entry()
{
}
touch_start(integer total_number)
{
dialog();
}
listen( integer channel, string name, key id, string message )
{
if (message == "<< PREV";)
{
llMessageLinked(LINK_THIS , 0, "back", NULL_KEY);
llListenRemove(h);
}
if (message == "NEXT >>";)
{
llMessageLinked(LINK_THIS , 0, "forward", NULL_KEY);
llListenRemove(h);
}
if (message == "CANCEL";)
{
llListenRemove(h);
}
}
}

Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
11-01-2008 00:33
Well - just issue the dialog()-call again when you receive Next or Previous:

CODE


key id;
string mess = "demo";
list menu = ["<< PREV","CANCEL","NEXT >>"];
integer chan;
integer h;
//================================================== =====
init()
{
llListenRemove(h);
key id;
h = llListen(chan, "",id, "");
}
//================================================== ====
dialog()
{
id = llDetectedKey(0);
chan = llFloor(llFrand(100000.0)) + 1000;
init();
llDialog(id,mess,menu,chan);
}
//================================================== ===
default
{
state_entry()
{
}
touch_start(integer total_number)
{
dialog();
}
listen( integer channel, string name, key id, string message )
{
if (message == "<< PREV")
{
llMessageLinked(LINK_THIS , 0, "back", NULL_KEY);
dialog();
}
if (message == "NEXT >>")
{
llMessageLinked(LINK_THIS , 0, "forward", NULL_KEY);
dialog();
}
if (message == "CANCEL")
{
llListenRemove(h);
}
}
}

Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
11-01-2008 00:52
I tried it but strangely , it doesn't work
Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
11-01-2008 00:55
oh solved lol, init() removes the listen , it works when I use the llDialog command directly , instead of whole function .
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
11-01-2008 01:01
Yeah - sorry - didn't have my 2nd cup of coffee, yet :)

I actually wonder, why it worked before since you used llDetectedKey(0) in your dialog()-function. llDetectedKey() only makes sense in touch/sensor-events.

You have to pass the toucher's key to the dialog-function (and to your init-function), then it should work.

In the touch-start-event, you pass llDetectedKey(0) to the two functions.
in the listen-event, you use the id which is passed to the event...

HTH

P.S. I actually wonder, why you're using a second function (init) to set the listener - you could easily do that in the dialog-function...


CODE


string mess = "demo";
list menu = ["<< PREV","CANCEL","NEXT >>"];
integer chan;
integer h;
//================================================== =====
init(key toucher)
{
llListenRemove(h);
h = llListen(chan, "",toucher, "");
}
//================================================== ====
dialog(key toucher)
{
chan = llFloor(llFrand(100000.0)) + 1000;
init(toucher);
llDialog(toucher,mess,menu,chan);
}
//================================================== ===
default
{
state_entry()
{
}

touch_start(integer total_number)
{
dialog(llDetectedKey(0));
}
listen( integer channel, string name, key id, string message )
{
if (message == "<< PREV")
{
llMessageLinked(LINK_THIS , 0, "back", NULL_KEY);
dialog(id);
}
if (message == "NEXT >>")
{
llMessageLinked(LINK_THIS , 0, "forward", NULL_KEY);
dialog(id);
}
if (message == "CANCEL")
{
llListenRemove(h);
}
}
}

Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
11-01-2008 01:34
aww, this make sense, I am still novice on scripting , thanks a lot

From: someone

P.S. I actually wonder, why you're using a second function (init) to set the listener - you could easily do that in the dialog-function...

I added dialog function later and init was already there :) silly me, as soon as it works it doesn't take my attention.