llDialog numbered buttons from list?
|
Drax Ogrimund
Registered User
Join date: 24 Aug 2009
Posts: 7
|
08-24-2009 13:33
Hi I hope someone can help me out - I have adapted a script that produces a sort of multi-page llDialog from a preset list so that it now populates the list from a http request from a server. That works fine.
The problem I have is that each button is named according to the particular item in the list and as a result is limited to a few characters. To get around this I would like a numbered list in the 'message' part of the dialog and then the corresponding buttons numbered (not titled).
So something like this:
___________________________
1. First Item 2. Second Item 3. Third Item etc
[ 1 ] [ 2 ] [ 3 ] etc [ Next ]
____________________________
Instead of: _______________________
Your message etc
[ First Item ] [ Second Ite ] [ Third Item ] etc [ Next ]
____________________________
I have pulled apart a few scripts from the forums here but they seem to rely on notecards and my knowledge on lists is basic so I'm struggling a little.
If anyone can point me in the right direction (or give a little, basic example of breaking a list down in a way that the buttons can be numbered etc) it would be appreciated!
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
08-24-2009 13:49
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
08-24-2009 14:23
send a list of numbers (properly ordered) to the dialog, and in the list use the numbers to reference the list of items by their index 
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Drax Ogrimund
Registered User
Join date: 24 Aug 2009
Posts: 7
|
08-24-2009 14:38
From: Void Singer send a list of numbers (properly ordered) to the dialog, and in the list use the numbers to reference the list of items by their index   Errr... I can understand the logic but I'm not entirely sure how to implement it! So, from the list created from the http response, I have a list such as: list wibble = ["Emma Roids","Hugh Jars","Heidi Vodka","Albert Ross","Drew Peacock"]; And what I need to do is associate the index 0 with Emma, 1 with Hugh, 2 with Heidi etc. Then put the numbers onto the buttons (these vary depending how many entries are downloaded) and display the listings in the message. How would you implement that - via a strided list somehow? I'm not looking for someone else to do the dirty work for me but I'm just trying to get my grey matter around lists lol.
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
08-24-2009 14:46
In it's simplest form: list wibble = ["Emma Roids","Hugh Jars","Heidi Vodka","Albert Ross","Drew Peacock"]; list idxList = [0,1,2,3,4];
default { touch_start(integer n) { llListen(-2312,"","",""); llDialog(llDetectedKey(0),"test",idxList, -2312); } listen(integer channel, string name, key id, string msg) { llOwnerSay(llList2String(wibble, (integer)msg)); } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
Drax Ogrimund
Registered User
Join date: 24 Aug 2009
Posts: 7
|
08-24-2009 14:49
Oooh hangon, penny dropped.
The dialog buttons are numbered based on the number of elements in the list, yeah?
Then, when the number is clicked, it tells the script to do a search through the list based on the index.
The dim light is slowly dawning on me - or is that a train?!
|
Drax Ogrimund
Registered User
Join date: 24 Aug 2009
Posts: 7
|
08-24-2009 14:52
From: Jesse Barnett In it's simplest form: list wibble = ["Emma Roids","Hugh Jars","Heidi Vodka","Albert Ross","Drew Peacock"]; list idxList = [0,1,2,3,4];
default { touch_start(integer n) { llListen(-2312,"","",""); llDialog(llDetectedKey(0),"test",idxList, -2312); } listen(integer channel, string name, key id, string msg) { llOwnerSay(llList2String(wibble, (integer)msg)); } }
Thanks Void & Jessie - I think I understand it more now. When I come inworld tomorrow I'll get stuck into this. Cheers!
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
08-24-2009 14:55
From: Drax Ogrimund Oooh hangon, penny dropped. Glad to see you learning. Next bit of magic is to autopopulate the idxlist based on the length of the wibble list like so: list wibble =["Emma Roids", "Hugh Jars", "Heidi Vodka", "Albert Ross", "Drew Peacock"]; list idxList;
default { state_entry() { integer len = llGetListLength(wibble); integer i; for(i = 0; i < len; ++i){ idxList += i; } } touch_start(integer n) { llListen(-2312, "", "", ""); llDialog(llDetectedKey(0), "test", idxList, -2312); } listen(integer channel, string name, key id, string msg) { llOwnerSay(llList2String(wibble, (integer) msg)); } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
Drax Ogrimund
Registered User
Join date: 24 Aug 2009
Posts: 7
|
08-24-2009 15:28
From: Jesse Barnett Glad to see you learning. Next bit of magic is to autopopulate the idxlist based on the length of the wibble list like so:
integer len = llGetListLength(wibble); integer i; for(i = 0; i < len; ++i){ idxList += i; } }
Gotcha - its a for loop which is saying that the counter (i) is zero and whilst it is less than the list length, increase i (the counter) by 1 and add that to the list 'idxList'. Once the whole list is done, reference that list as the dialog buttons. So now I need to put a Previous and Next button - I think that would mean llDialog would need to be limited to returning 10 entries at a time plus the "Previous" and "Next" buttons - would that mean using a temporary list, referencing the idxList and using List2List somehow?
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
08-24-2009 17:59
From: Drax Ogrimund Gotcha - its a for loop which is saying that the counter (i) is zero and whilst it is less than the list length, increase i (the counter) by 1 and add that to the list 'idxList'. Once the whole list is done, reference that list as the dialog buttons.
So now I need to put a Previous and Next button - I think that would mean llDialog would need to be limited to returning 10 entries at a time plus the "Previous" and "Next" buttons - would that mean using a temporary list, referencing the idxList and using List2List somehow? i can always start at 1 instead of zero and end at 11 instead of list length. Take a look here for more on lists: http://lslwiki.net/lslwiki/wakka.php?wakka=list
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
Drax Ogrimund
Registered User
Join date: 24 Aug 2009
Posts: 7
|
08-25-2009 00:04
Hmmm trying those scripts out gives me an error message:
llDialog: button list must contain only strings
I'm guessing its something with the idxList containing integers and not strings?
|
Drax Ogrimund
Registered User
Join date: 24 Aug 2009
Posts: 7
|
08-25-2009 00:22
Well, had a play with it and tweaked it from: idxList += i; to idxList += [(string)i]; that displays the buttons  - now to tally them up!
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
08-25-2009 03:23
From: Drax Ogrimund Well, had a play with it and tweaked it from: idxList += i; to idxList += [(string)i]; that displays the buttons  - now to tally them up! Ahh,You are right. I tested in LSLEditor and it would not have caught that. Glad you figured it out.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
08-25-2009 08:32
One note I'd like to throw in is the ordering of buttons on dialogues, as it's left to right and top to bottom which can make for messy dialogues if you don't sort them properly. You can sort them into the correct order by doing:
integer l = ((butons != []) % 3); if (l == 2) buttons += [" "]; else if (l == 1) buttons += [" ", " "]; buttons = llListSort(llListSort((buttons = []) + buttons, 1, TRUE), 3, FALSE);
That should ensure your buttons go from 1 to 12 or whatever.
To explain the code; the (buttons != []) is a quick way to get a list's length, and is less costly than llGetListLength(), that same line is using module (%) to see if the buttons list contains a multiple of 3 buttons or not. If it returns a non zero value (1 or 2), then it adds some blank buttons to pad the result.
The statement ((buttons = []) + buttons) is used here to save memory, this works because the buttons list is being overwritten as a result of that line. The line itself sorts the list first into ascending order, which you may be able to skip in this particular case as your list is a load of numbers which are going to be in order anyway I think? The other (outer) sort then sorts the list in groups of 3 elements so that they're ordered correctly by the dialogue.
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|