Jump to content




Help with a scrolling multiple choice selection

lua

  • You cannot reply to this topic
4 replies to this topic

#1 Himself12794

  • Members
  • 56 posts

Posted 12 February 2014 - 05:35 PM

I'm writing a function to allow selection from a list of options, returning the index of the selected choice. At first, it only worked if the length of the items fit onto the page, then I modified it, so now it can do a list if the items fit on a second page, at the cost of losing the header. However, anything larger than two pages just does weird things. Anyone know how I can fix it?
Here's the code:
Spoiler
Help is appreciated.

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 12 February 2014 - 06:09 PM

I haven't tested either your code nor mine, but best I can make out, rather then this:

Spoiler

... you may want something like this:

Spoiler

Also, the keys API is worth a look. It allows you to rewrite stuff like this:

        if key == 208 --down arrow
        or key == 31 then -- S

... like this:

        if key == keys.down or key == keys.s then

Using these pre-defined constant variables stored in that API means you don't need to work out the numeric codes yourself.

#3 Himself12794

  • Members
  • 56 posts

Posted 12 February 2014 - 06:35 PM

 Bomb Bloke, on 12 February 2014 - 06:09 PM, said:

I haven't tested either your code nor mine, but best I can make out, rather then this:

Spoiler

... you may want something like this:

Spoiler

Also, the keys API is worth a look. It allows you to rewrite stuff like this:

		if key == 208 --down arrow
		or key == 31 then -- S

... like this:

		if key == keys.down or key == keys.s then

Using these pre-defined constant variables stored in that API means you don't need to work out the numeric codes yourself.
That does help maintain the header, but there's still weirdness with printing the options.

#4 Himself12794

  • Members
  • 56 posts

Posted 12 February 2014 - 11:38 PM

So I made something that works, but not exactly as I wish for it too. I don't wish for the values to scroll until selection hits the bottom, but this code scrolls through the rest of values until they no longer fill the page. It's a fair compromise for what I want, but I will work until I get the results.
Here's the code for this:
Spoiler


#5 Himself12794

  • Members
  • 56 posts

Posted 12 February 2014 - 11:58 PM

I got it! Runs just as I wanted!
Here's the code:
Spoiler

Edited by Himself12794, 13 February 2014 - 12:56 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users