Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llDialog no longer working?

Pumpkin Hoorenbeek
Registered User
Join date: 5 May 2007
Posts: 15
06-16-2008 17:50
Hello can anyone tell me why the following script doesn't work correctly anymore?

It used to do multiple pages of items, but now it gives the "llDialog: button list too long, must be 12 or fewer entries" error.

Can anyone please help??

CODE

// Drink Give
// (c)Erisia Pussycat
// I hereby give this script to public domain

//drinks
list drinks = [];

//communication
integer channel = 71;
integer listenh;

//page
integer curpage;

//Build list of drinks
buildList() {
integer num;
integer i;
num = llGetInventoryNumber(INVENTORY_OBJECT);
for (i = 0 ; i < num ; i++) {
drinks = drinks + [llGetInventoryName(INVENTORY_OBJECT, i)];
}
}

//get the drink list on page x
list drinksForPage(integer page) {
list result = llList2List(drinks, page * 11, (page + 1) * 11 - 1);
return result;
}

//display list of choices to user
displayChoices(key user, integer page) {
list pagedrinks = drinksForPage(page);
if (curpage > 0) {
//Add previous
pagedrinks = pagedrinks + ["Previous"];
}
if ((curpage + 1) * 11 - 1 < llGetListLength(drinks)) {
//Add next
pagedrinks = pagedrinks + ["Next"];
}
llDialog(user, "\nPage " + (string)(curpage+1) + ": \n\nPlease Choose The Food You Would Like.", pagedrinks, 71);
}

//Comm
openCommunication() {
closeCommunication();
listenh = llListen(channel, "", NULL_KEY, "");
}

closeCommunication() {
llListenRemove(listenh);
}

// drink giving
giveDrink(key user, string drink) {
//safety
if (llGetInventoryType(drink) == INVENTORY_OBJECT) {
llGiveInventory(user, drink);
}
}

//Init
init() {
buildList();
curpage = 0;
llSetText("", <1,1,1>, 1.0);
}


// states
default
{
state_entry()
{
init();
}

touch_start(integer total_number)
{
//show list to AV and listen for choice
openCommunication();
displayChoices(llDetectedKey(0), curpage);
//Star timeout timer
llSetTimerEvent(120);
}

timer() {
//no news from user, stop listening
closeCommunication();
//reset page
curpage = 0;
}

listen(integer chan, string name, key id, string message) {
//special cases: previous next
if (message == "Previous") {
curpage--;
//safety
if (curpage < 0) {
curpage = 0;
}
displayChoices(id, curpage);
} else if (message == "Next") {
curpage++;
//safety
if (curpage * 11> llGetListLength(drinks)) {
curpage = 0; //shoot back to page 0. This shouldnt happen anyway.
}
displayChoices(id, curpage);
} else {
//give drink
giveDrink(id, message);
}
}

changed(integer change) {
if ((change & CHANGED_INVENTORY) != 0) {
//inventory changed, rescan
llResetScript();
}
}
}

Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
Quick fix
06-16-2008 18:37
Here's a quick fix, you should be able to fix it up further. If you have any questions, IM me in game.

CODE

//
CODE

// Drink Give
// (c)Erisia Pussycat
// I hereby give this script to public domain
//drinks
list drinks = [];
//communication
integer channel = 71;
integer listenh;
//page
integer curpage;
//Build list of drinks
buildList() {
integer num;
integer i;
num = llGetInventoryNumber(INVENTORY_OBJECT);

for (i = 0 ; i < num ; i++)
{
drinks = drinks + [llGetSubString(llGetInventoryName(INVENTORY_OBJECT, i),0,23)];//quick fixes
if(i > 11)
i = 30;
}
}
//get the drink list on page x
list drinksForPage(integer page) {
list result = llList2List(drinks, page * 11, (page + 1) * 11 - 1);
return result;
}
//display list of choices to user
displayChoices(key user, integer page) {
list pagedrinks = drinksForPage(page);
if (curpage > 0) {
//Add previous
pagedrinks = pagedrinks + ["Previous"];
}
if ((curpage + 1) * 11 - 1 < llGetListLength(drinks)) {
//Add next
pagedrinks = pagedrinks + ["Next"];
}
llDialog(user, "\nPage " + (string)(curpage+1) + ": \n\nPlease Choose The Food You Would Like.", pagedrinks, 71);
}
//Comm
openCommunication() {
closeCommunication();
listenh = llListen(channel, "", NULL_KEY, "");
}
closeCommunication()
{
llSetTimerEvent(0.0);//timers don't close themselves
llListenRemove(listenh);
}
// drink giving
giveDrink(key user, string drink) {
//safety
if (llGetInventoryType(drink) == INVENTORY_OBJECT) {
llGiveInventory(user, drink);
}
}
//Init
init() {
buildList();
curpage = 0;
llSetText("", <1,1,1>, 1.0);
}

// states
default
{
state_entry()
{
init();
}
touch_start(integer total_number)
{
//show list to AV and listen for choice
openCommunication();
displayChoices(llDetectedKey(0), curpage);
//Star timeout timer
llSetTimerEvent(120);
}
timer() {
//no news from user, stop listening
closeCommunication();
//reset page
curpage = 0;
}
listen(integer chan, string name, key id, string message) {
//special cases: previous next
if (message == "Previous") {
curpage--;
//safety
if (curpage < 0) {
curpage = 0;
}
displayChoices(id, curpage);
} else if (message == "Next") {
curpage++;
//safety
if (curpage * 11> llGetListLength(drinks)) {
curpage = 0; //shoot back to page 0. This shouldnt happen anyway.
}
displayChoices(id, curpage);
} else {
//give drink
giveDrink(id, message);
}
}
changed(integer change) {
if ((change & CHANGED_INVENTORY) != 0) {
//inventory changed, rescan
llResetScript();
}
}
}
Pumpkin Hoorenbeek
Registered User
Join date: 5 May 2007
Posts: 15
06-16-2008 20:34
thank you thank you thank you!

that fixed it!

Only issue I would like to point out to anyone that may use this script in world is if you plan on using it in multiple objects that are within 20 meters of each other you need to set different listen channels for each one or else the menus will try to control both/all objects at once.

Thanks again!!
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
06-16-2008 20:53
why dont you just have it set a random number as the chat channel when it starts up