Jump to content




Selector Menu


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

#1 grand_mind1

  • Members
  • 207 posts

Posted 30 March 2013 - 08:00 PM

I want to try to make a simple menu that will select different things on a list depending on which keys you press. I've tried to make this many times before and have completely failed. It always does something completely different and I end up giving up until I feel like trying to make another one. I've tried to look at and use other people's menu programs and they work fine but I don't understand them. I want to be able to make my own and not just copy off of other people. I know you aren't really supposed to ask other people to just write code for you in ask a pro but I just don't even know where to begin. Could someone please try to help me understand how to do this?
Help is appreciated!
Thanks! :D


P.S. Sorry if this doesn't make a lot of sense. I wrote it at 3 in the morning... :)

#2 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 30 March 2013 - 08:53 PM

I get your point, it's frustrating when your code doesn't work.

As you said, not a lot of people thinks that you should just give so called "free" code. But we can at least help you a lot if you give us a code to start off with.

You see, when it comes to doing stuff for others the forums community oftenly prefers "correcting" code instead of "creating" code.

#3 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 30 March 2013 - 09:19 PM

If it was me, I'd go sleep and try when I'm more energised. If the doesn't work do something like go for run or even go on a trampoline if you have one.

But as you have done this before...

What I would do is have a table of all the items, have an integer with the selected item. When an up or down key is pressed reduce or increase the selected integer.

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 30 March 2013 - 11:48 PM

Another approach that you can take is one that the CC devs take, where the first letter of each menu item is bound to its relevant key. however this means you cannot have 2 entries with the same name.

#5 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 31 March 2013 - 01:34 AM

I presume we all mean a list something like this:
Spoiler
Right?

#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 31 March 2013 - 02:06 AM

View Postjag_e_nummer_ett, on 31 March 2013 - 01:34 AM, said:

I presume we all mean a list something like this:
-image snip-
Right?
Yes that is what I am assuming is desired. or like the 'edit' programs menu...

#7 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 31 March 2013 - 03:33 AM

So you want to learn how to make a menu program?
I can show you a basic here..
Spoiler


#8 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 31 March 2013 - 10:18 AM

Many people ask this so I kept one I made and always show people this one, pastebin

#9 grand_mind1

  • Members
  • 207 posts

Posted 31 March 2013 - 06:16 PM

So, I tried to take oeed and jag_e_nummer_et's advice and I took a break from coding anything for a day. I hardly even touched my computer. When I sat back down and tried to make a new selector menu it worked! Everything suddenly made sense and I could see where I had done things wrong. From looking at others people's code I know it is not very good, but it works and that's all I care about. I'm gonna post the code down below to see if I can get any pointers on what I can do better. I feel like the logic where it tries to decide what to do if a key is pressed is a bit excessive and could be improved.

I've commented most of the code to try to explain my reasoning for certain things
Code:
http://pastebin.com/gATUjxfn

I can also very easily expand off of this for more options and different keys to press.
Thanks to everyone who tried to help me!
THANKS!!! :D

#10 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 01 April 2013 - 12:45 AM

I am happy that it worked! OuO





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users