These forums are CLOSED. Please visit the new forums HERE
How to scipt a menu sustem for an unknow quantity. |
|
|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
03-15-2007 06:23
On several occasions I have needed to script a menu system without knowing the total number of items that might need to be included. Because I have never figured it out, I have had to settle with one that has a predetermined maximum and then script to cover all the possibilities been less than 12 to that maximum. All of my attempts to do avoid limiting the possible number have died in a convoluted mess, but I keep trying because I continue to believe it can be done with the right set of nifty code trick.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-15-2007 06:39
On several occasions I have needed to script a menu system without knowing the total number of items that might need to be included. Because I have never figured it out, I have had to settle with one that has a predetermined maximum and then script to cover all the possibilities been less than 12 to that maximum. All of my attempts to do avoid limiting the possible number have died in a convoluted mess, but I keep trying because I continue to believe it can be done with the right set of nifty code trick. Its actually relatively simple. The list that you display is limited to 12 but this can be a subset of the total list. Just keep track of where you are in the list (i.e. first entry to display) and rebuild the list each time. |
|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
But
03-15-2007 10:11
Unless I am missing something, the problem with that approach is the insertion on (next) and (back) option in the appropriate places in sublists.
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-15-2007 10:28
Yes, you need to display up to 10 (or less) items from the list at a time, and then figure out if you need a next, prev, or both buttons. And you do that by checking to see if you're at either end of the main list or not. And then if the user hits prev or next, you move up or down in the main list.
So... don't try to insert next and prev buttons in the main list. Figure out which entries from the main list you need to currently display (depends on where you are, how many items you're displaying per screen, etc), generate that sub-list, then independently figure out if you need a next, a prev, or both buttons. |
|
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
|
03-15-2007 14:39
Yep...it's a very simple script really...either run 11 buttons with a "More..." or 10 buttons with a "<<Back" and "Forward>>" type button tacked on to the last.
All you need is a counter to see how many times someone has clicked a "more" button so that you can pull from your button list starting from the appropriate place. After pulling from the list, increase your counter (or, if it exceeds your list-length, set zero). _____________________
--AeonVox--
Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music. |
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-15-2007 14:45
As Ziggy said, its not a problem since you dont touch the main list at all.
I've left out the populating of the list and not bothered filtering items of greater than 24 characters. CODE
|
|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
Thanks all
03-16-2007 17:32
Your comments have helped me think this through. Thanks to Ziggy, Kenn, and especially Newgate who when beyond the call of duty by providing and example script. Time after time one or more of you have saved my ____.
Mod |