Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with dialog menu - need a little help debugging :)

Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
09-17-2008 06:42
Hello again all.

I didnt like the wiki buttons for pages so i decided to have a go at doing my own and im in need of some help bug bashing it will try to describe the problem in detail.

the page order is a little messed up right now.
the next and previous page scrolling just stops after a while and i cant work out why.

But i did give it a good go to rewrite the scroll buttons if any one can help me debug this and get it working would be great.

CODE


list buttons;
integer Choices;
integer PageNum;
integer page;
integer num_pages;
integer num_items;

dialog_buttons()
{
integer firstchoice;
integer lastchoice;
integer Choices;
integer MaxPage = 6;

list buttons_Bar;

Choices = llGetListLength(ColourName); // our taken data from notecard globally list at Colourname

if (Choices <=6)
{
buttons = Desc;
page = 0;
}

else
{
integer nPage = (Choices + MaxPage -1)/ MaxPage;

if (num_pages <1 || num_pages > nPage)
{
num_pages = 0;
}

firstchoice = (num_pages -1) * MaxPage;
lastchoice = firstchoice + MaxPage -1;

if (lastchoice >= Choices)
{
lastchoice = Choices;
}
}

if (num_pages == 1)
{
buttons_Bar = ["<< Prev", "<< Exit >>", "Next >>"];
}

else if (page == 0) buttons_Bar = ["<< Prev", "<< Exit >>", "Next >>"];

else if (page == num_pages-1)
{
buttons_Bar = ["<< Prev", "<< Exit >>", "Next >>"];
}

else buttons_Bar = ["<< Prev", "<< Exit >>", "Next >>"];

buttons = buttons_Bar + llList2List(ColourName,firstchoice, lastchoice);
}



What i did was take the wiki's section on putting the names onto buttons and another example that i had to change the buttons over and i think i made a right mess of it.

below is the tail end of the data server that catchs the info to put onto the buttons

CODE

// Snipped lines
else
{
num_items = llGetListLength(Desc);

num_pages = num_items / 6;

if ((num_items - (num_pages * 6))>0) num_pages++;
}
// Snipped Lines


And below this is the listen catching the buttons when its clicked to scroll

CODE

//Snipped lines
else if (message == "<< Prev")
{
num_pages--;
dialog_buttons();
}
else if (message == "Next >>")
{
num_pages++;
dialog_buttons();
}
// Snipped Lines


I snipped off lines here not because i didnt want to post the whole code but its just a data server and that is working fine for routing the information out i need.

In this case it was just a seperated name and vector from notecard.

Ok will try to explain about the segments.

What i did was use try to add my own previous and next buttons so the pages would constant loop with the different data on that was read.

The wiki was a base plate as i didnt like the way the buttons on that scrolled at all stuck with a page number on and all and i wanted something i could say i done that bit to make it work as i had intended.

If any one can help me fix this mess i made the rest of the script is fine without no bugs or problems its just i made a moppy mess of the buttons :(

pretty much what i wanted was the data dug from my dataserver printed onto the buttons with a working next and previous page scroll :(
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
09-17-2008 07:04
Without trying it and out of the blue, I guess your problem is in this part:

CODE


integer nPage = (Choices + MaxPage -1)/ MaxPage;

if (num_pages <1 || num_pages > nPage)
{
num_pages = 0;
}

firstchoice = (num_pages -1) * MaxPage;
lastchoice = firstchoice + MaxPage -1;

if (lastchoice >= Choices)
{
lastchoice = Choices;
}




note every appearance of «-1» - this won't deduct 1 but make 1 a negative number. And thus, the server will misinterpret it.

Always put a space between the minus-sign and the number to deduct.

e.g.:

MyVar -1; // will not work
MyVar - 1; // will work
Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
09-17-2008 07:25
aaaha thank you i will give that a try just dabbling with getting the buttons to work how i want it to just didnt like the wiki's multipage dialog lol.

Ok it seems to be semi working now it still seemingly get stucks i will keep working at tweaking the settings a little hopefully i maybe able to get it working finally but on the whole im finding LSL scripting a nice challenge lol.

Edit 2.

Found a work around got the dialog to blank the first button on the starting page since it was that Prev page giving me the sticking problems.

so now first page start bit is blank and it will scroll normall with the next buttons and prev after the first page :)

thanks for the help! finally managed to tweak it just right lol
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
09-17-2008 09:18
Another thing I saw. you're having the same navig-button set everytime the dialog is called. So all the if's wouldn't be needed...

Suggestion how to do it:

CODE


if (num_pages == 1){
// Only one page - no prev/next-button needed will fail if called
buttons_Bar = ["<< Exit >>"];
}else if (page == 0){
// First page - no prev-button needed - will fail if called
buttons_Bar = ["<< Exit >>", "Next >>"];
}else if (page == num_pages - 1){
// last page - no next-button needed - will fail if called
buttons_Bar = ["<< Prev", "<< Exit >>"];
}else{
buttons_Bar = ["<< Prev", "<< Exit >>", "Next >>"];
}

buttons = buttons_Bar + llList2List(ColourName,firstchoice, lastchoice);

Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
09-18-2008 03:03
Thank you for the pointers i manage to crack the puzzle this morning and now have a notecard info adapting dialog pages with full working Prev and Next scrolling ability

had to trim off the page 0 and page - 1 statements put in the if num_pages = 1 dual scroll bars and had then went straight to the else statement for all invbetween pages IE any data added after that for the pages.

Thanks for the advice you have been a great help the last few forums post :)

EDIT Now Fixed the prev next page scrolling Thank you again!
Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
09-18-2008 11:44
Dont know if any exist other than the wiki but can any one point me to a multi page dialog thats open source that i can learn from putting my info onto buttons isnt a problem with what i have learnt.

But the problem im having is finding a dialog with multi paging ability based on the ammount of data i feed to it from a note card that works properly. i found a tempory workaround for the time being while im working on the rest of my larger project.

If any one knows a nice multi page dialog with forward and back buttons that is basically totally empty of anything but a Next , Prev button and will scroll around pages now matter how much data you feed it would be appreciated have tried to build my own but without a better example other than the wiki's to guide me im hitting walls.

The main problems im hitting is i can get the next button to scroll without problems but going backwards with the previous is hitting a wall quicker than anything.

If any one can point me to an open source i may look at for reference would be great if there is none then i will try to get what i have scripted thus far working proper.