Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

need to loop a menu

Scomac Hicks
Registered User
Join date: 27 May 2006
Posts: 2
08-25-2006 06:47
I have a sound script that I would like to loop the menu and can't seem to find out how. I have searched the forums and can't seem to find the answer anywhere. Any help would be greatly appreciated!

Scomac Hicks

Here is the text of the sound script:

integer MENU_CHANNEL = -198284; // Or ohther negative number: negative channels wont show AV saying!
list MENU_OPTIONS = ["sound1","sound2","sound3","sound4"];
integer channelControl;

default
{
state_entry()
{
// Not shown here but looping the menu_options you could use
// llPreloadSound() - see LSL wiki
channelControl = llListen(MENU_CHANNEL,"",NULL_KEY,"";);
llListenControl(channelControl,FALSE); // Don't listen just yet
}

touch(integer num_detected)
{
llListenControl(channelControl,TRUE); // Start listening for response
llSetTimerEvent(60); // Make sure 60s from now channel is closed again
llDialog(llDetectedKey(0),"Select the sound:",MENU_OPTIONS,MENU_CHANNEL);
}

listen(integer channel,string who,key id,string message)
{
if (channel==MENU_CHANNEL)
{
// message = name of button
// assume button name = name of soundfile
llPlaySound(message,1.0);
// Done, stop timer and channel
llSetTimerEvent(0);
llListenControl(channelControl,FALSE);
}
}

timer()
{
// Timeout wiating for dialog response,stop timer and channel
llSetTimerEvent(0);
llListenControl(channelControl,FALSE);
}
}
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
08-25-2006 08:14
The short answer is that you have to redisplay the llDialog each time you process its response (llDialog is one time only).

The longer answer is that you should really pull the llDialog code out of your main-line code into a function...


CODE
integer MENU_CHANNEL = -198284; // Or ohther negative number: negative channels wont show AV saying!
list MENU_OPTIONS = ["sound1","sound2","sound3","sound4"];
integer channelControl;
key uKey;

mnuDialog(key uKey)
{
llListenRemove(channelControl);
channelControl = llListen(MENU_CHANNEL, "", uKey, "");
llDialog(uKey, "Select the sound:", MENU_OPTIONS, MENU_CHANNEL)
llSetTimerEvent(60);
}

default
{
state_entry()
{
// Not shown here but looping the menu_options you could use
// llPreloadSound() - see LSL wiki
}

touch(integer num_detected)
{
uKey = llDetectedKey(0); // <==== preserve the user's key
mnuDialog(uKey); // <=== display the dialog
}

listen(integer channel,string who,key id,string message)
{
if (channel==MENU_CHANNEL)
{
// message = name of button
// assume button name = name of soundfile
llPlaySound(message,1.0);
mnuDialog(uKey); // <=== redisplay the menu dialog
}
}

timer()
{
// Timeout wiating for dialog response,stop timer and channel
llSetTimerEvent(0);
llListenRemove(channelControl);
}
}
Scomac Hicks
Registered User
Join date: 27 May 2006
Posts: 2
08-28-2006 13:29
I tried to add that to the sounds script I am using but now am getting a syntax error. I know next to nothing about scripting other than making small changes. Can you tell me what I am doing wrong? Is there a certain place I need to be placing this within the script or is this the script I am supposed to use?

Thanks,

Scomac Hicks
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
08-28-2006 14:33
My bad. I never syntax checked it, I just typed it off the top of my head. :D

I can see there's a semi colon missing at the end of this line:

llDialog(uKey, "Select the sound:", MENU_OPTIONS, MENU_CHANNEL);

...and that'll be the fella if the syntax check occured at the start of the line following.
eldodo Fierrens
Registered User
Join date: 27 Feb 2008
Posts: 5
12-13-2008 04:26
Hi,

Is it possible to add a notecard with some uuid's which will be played by the dialog menu?
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
12-13-2008 05:39
text yes, but a key is too long to fit in the dialog, as are most avatar names, because theres a 10 (?) letter limit for each dialog button name.

so, ah screw llDialog, its annoying, it has no command to close it so it needs a timeout timer for that, its WASITNG listens and lists, a shutload of code and server bandwidth, it s hardly customizable, and since a script can now know what coordinates a texture is touched on, and since every xy-text prim can display anything better than llmenu:

llDialog() wins the worst function award 2008.

oh, there is this barely known and barely available command http://wiki.secondlife.com/wiki/LlTextBox that is like llMenu, except that, it has a command line to input your own text, but its also a waste of memory like llDialog, so, like i sayd:

llDialog() wins the worst function award 2008.
eldodo Fierrens
Registered User
Join date: 27 Feb 2008
Posts: 5
12-13-2008 06:02
Oh sorry I made a mistake...
I would like that the script takes uuids from a notecard and then we will be able to choose sounds by the menu.

For example :

A notecard :

//Here is sounds names and their uuids
Boom
facf4c22-dd3c-d3fe-3730-77a6b4495118

Crack
e2a90af7-62e3-4d1c-cf39-08a49dfdf94b

...

---------------------------------------------------

Dialog menu :

[Boom] [Crack]
[.........] [.........]

---------------------------------------------------

I hope this explanation will be better...
eldodo Fierrens
Registered User
Join date: 27 Feb 2008
Posts: 5
12-13-2008 13:52
I tried to make the script from another but there is a mistake :

CODE

string card;
integer line;
key query;

integer part=0;
integer channel=55000;
integer handle;
integer v;
integer w;

list soundlist = [];
list soundnames = [];
list b;

menu(key id)
{
if ( v < 13 )
{
b = soundnames;
}

else
{
if (part == 0)
b = llList2List(soundnames, 0, 1) + [">>"] + llList2List(soundnames, 2, 10);

else if (part == w)
b = llList2List(soundnames, part * 10 + 1, part * 10 + 2) + ["<<"] + llList2List(soundnames, part * 10 + 2, part * 10 + 10);

else if ( 0 < part < w)
b = llList2List(soundnames, part * 10 + 1, part * 10 + 1) + ["<<"] + [">>"] + llList2List(soundnames, part * 10 + 2, part * 10 + 10);
}
llDialog(id, "Choisissez un son:", b, 55000);
}

default
{
state_entry()
{
if (llGetInventoryNumber(INVENTORY_NOTECARD) == 0)
{
llOwnerSay("Aucune notecard n'a été détectée dans l'inventaire de l'objet.");
}
else
{
card = llGetInventoryName(INVENTORY_NOTECARD, 0);
query = llGetNotecardLine(card, line = 0);
}
}

changed(integer c)
{
if (c & CHANGED_INVENTORY) llResetScript();
}

dataserver(key id, string data)
{
if (query != id) return;
if (data == EOF) return;
integer i = llSubStringIndex(data, "=");
if (i >= 0) {
soundnames += [llGetSubString(data, 0, i - 1)];
soundlist += [llDeleteSubString(data, 0, i)];
}
query = llGetNotecardLine(card, ++line);
}

touch_start(integer total_number)
{
key id = llDetectedKey(0);
llListenRemove(handle);
handle = llListen(55000, "", id, "");
v = llGetListLength(soundnames);
w = llFloor( (v-3) / 10);
menu(id);
llSetTimerEvent(30.0);
}

timer()
{
llListenRemove(handle);
llSetTimerEvent(0.0);
}

listen(integer channel, string name, key id, string message)
{
if (message == ">>")
{
part += 1;
llSetTimerEvent(30.0);
menu(id);
return;
}

if (message == "<<")
{
part -= 1;
llSetTimerEvent(30.0);
menu(id);
return;
}

integer index = llListFindList(soundnames, [message]);
if (index < 0) return;
llPlaySound(llList2Key(soundlist, 1.0);
llListenRemove(handle);
llSetTimerEvent(0.0);
}
}
Stewart Poitier
Registered User
Join date: 10 Oct 2007
Posts: 11
12-13-2008 17:20
From: eldodo Fierrens
llPlaySound(llList2Key(soundlist, 1.0);

should be :

llPlaySound(llList2String(soundlist, index), 1.0);