Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Lists and Dialog menu

Samuel Beltran
Registered User
Join date: 10 May 2007
Posts: 7
05-26-2008 19:05
I have a list but how do I make it work so that it can be used by llDialog function?

Thanks
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
05-26-2008 21:33
Pretty much self explanatory with the comments

CODE

//Button Text
list dialogButtons = ["Button 1", "Button 2", "Button 3"];

//Dialog menu text
string dialogMessage = "Choose a button!";

// Channel for dialog menu to use/listen
// to listen on.
integer CHANNEL = -123456;

// a handle to reference the listen so it
// can be removed when not in use.
integer handle;
default
{
touch_start(integer total_number)
{
key avatar = llDetectedKey(0);
// get the avatar's key so llDialog
// knows who to give the menu to...

handle = llListen (CHANNEL, "",NULL_KEY,"");
// setup a listen event, save the handle so
// you can remove the listen later

llDialog (avatar, dialogMessage, dialogButtons, CHANNEL);
// show the dialog menu, wait for a button press
}

listen (integer channel, string name, key id, string message)
{
// when a button is pressed, this event will trigger
// channel (not CHANNEL), will contain the channel
// the listen was heard on... name, the avatar's
// name, id, the avatar's key and message will
// contain the same text that appears on the button
if (message == "Button 1")
{
llSay (0, "You pressed 'Button 1'");
// Put code here for button one...
}

if (message == "Button 2")
{
llSay (0, "You pressed 'Button 2'");
// Put code here for button two...
}

if (message == "Button 3")
{
llSay (0, "You pressed 'Button 3'");
// Put code here for button three...
}
llListenRemove (handle);
// remove the listen to reduce lag since
//it's no longer needed, it'll be setup
//again when touched.
}
}

Samuel Beltran
Registered User
Join date: 10 May 2007
Posts: 7
05-28-2008 22:31
I wasn't specific enough. I have a notecard that my script reads. I have a process that then filters through the information and constructs a list unique to that avatar. It then is suppose to take that list and make a dialog menu out of it. All I ever get though is:

TP Center: llDialog: all buttons must have label strings
TP Center: llDialog: all buttons must have label strings

Thanks
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
05-28-2008 23:37
From: Samuel Beltran
I wasn't specific enough. I have a notecard that my script reads. I have a process that then filters through the information and constructs a list unique to that avatar. It then is suppose to take that list and make a dialog menu out of it. All I ever get though is:

TP Center: llDialog: all buttons must have label strings
TP Center: llDialog: all buttons must have label strings

Thanks


use the unique list that you construct in the llDialog(). Cant really help you out without seeing what you're doing in the script. Post the script if you want more help with it.
Samuel Beltran
Registered User
Join date: 10 May 2007
Posts: 7
05-29-2008 00:41
CODE

// PUBLIC|GROUP|NAME|~LOCATION NAMECOORDS
list scoord;
list slocation;
string dMessage = "Choose a destination";
integer dchannel = -1976;
key avatar;
string kname;
integer nline;
string nlinetext;
string sname = "Teleport Index";
integer grouptest;
integer handle;
string sline;


default
{
touch_start(integer total_number)
{
avatar = llDetectedKey(0);
kname = llDetectedName(0);
nline = 1;
scoord = [""];
slocation = [""];
integer gtest = llDetectedGroup(0);
if (gtest == TRUE)
{
grouptest = TRUE;
}
else if (gtest == FALSE)
{
grouptest = FALSE;
}
llOwnerSay("Tested " + (string)grouptest);
handle = llListen(dchannel, "", NULL_KEY, "");
state list_maker;
}
}

state list_maker
{
state_entry()
{
nlinetext = llGetNotecardLine(sname, nline);
}
dataserver(key requested, string data)
{
llOwnerSay("I made it to the dataserver " + data);
if (data == EOF)
{
state dialog;
}
else
{
sline = data;
state test1;;
}
}
}

state test1
{
state_entry()
{
integer spacer = llSubStringIndex(sline, "|");
string test1 = llGetSubString(sline, 0, (spacer - 1));
llOwnerSay("test1 string: " + test1);
if ((integer)test1 == 1)
{
integer strip1 = llSubStringIndex(sline, "~");
integer strip2 = llSubStringIndex(sline, "<");
slocation += (string)llGetSubString(sline, (strip1 + 1), (strip2 - 1));
scoord += llGetSubString(sline, (strip2), -1);
nline = (nline + 1);
llOwnerSay("Test1 passed" + (string)nline);
state list_maker;
}
else
{
llOwnerSay("Test1 failed. Going to test2.");
sline = llGetSubString(sline, (spacer + 1), -1);
llOwnerSay(sline);
state test2;
}
}
}

state test2
{
state_entry()
{
integer spacer = llSubStringIndex(sline, "|");
string test2 = llGetSubString(sline,0, (spacer - 1));
llOwnerSay("test2 string: " + test2);
if (grouptest == 1 && (integer)test2 == 1)
{
integer strip1 = llSubStringIndex(sline, "~");
integer strip2 = llSubStringIndex(sline, "<");
slocation += (string)llGetSubString(sline, (strip1 + 1), (strip2 - 1));
scoord += llGetSubString(sline, (strip2), -1);
nline = (nline + 1);
llOwnerSay("Test2 passed" + (string)nline);
state list_maker;
}
else
{
llOwnerSay("Test2 failed. Going to test3.");
sline = llGetSubString(sline, (spacer + 1), -1);
state test3;
}
}
}

state test3
{
state_entry()
{
integer spacer = llSubStringIndex(sline, "|");
string test3 = llGetSubString(sline,0, (spacer - 1));
if (llToLower(test3) == llToLower(kname))
{
integer strip1 = llSubStringIndex(sline, "~");
integer strip2 = llSubStringIndex(sline, "<");
slocation += (string)llGetSubString(sline, (strip1 + 1), (strip2 - 1));
scoord += llGetSubString(sline, (strip2), -1);
nline = nline + 1;
llOwnerSay("Test3 passed" + (string)nline);
state list_maker;
}
else
{
llOwnerSay("Test3 failed. Going to listmaker.");
nline = (nline + 1);
state list_maker;
}
}
}

state dialog
{
state_entry()
{
if (slocation == [""])
{
llSay(0, "No allowed targets");
llResetScript();
}
handle = llListen(dchannel, "", NULL_KEY, "");
llOwnerSay("I made it to Dialog " + llList2CSV(slocation));
llDialog(avatar, dMessage, slocation, dchannel);
}
}


I used the ownersays to only track the progress of the script. It gets all the way to the llDialog and then I then get that error.
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
05-29-2008 04:41
That error is likely occuring because one of the list values you have passed to it is empty. Sooo ...

From what I can see sLocation will never have more than a single value and (maybee I' missing something) but not quite sure why:

slocation += (string)llGetSubString(sline, (strip1 + 1), (strip2 - 1));

... works. Shouldn't you have to cast to a list? In any case, what is the output of the line:

llOwnerSay("I made it to Dialog " + llList2CSV(slocation));
Samuel Beltran
Registered User
Join date: 10 May 2007
Posts: 7
05-29-2008 05:26
It is just a marker to let me know that the list isn't empty. In the notecard, using the format on the top, is how it filters information. I wonder if a third spot is opening up. Gotta check that.