Jump to content




Menu not working

help

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

#1 Draedo

  • Members
  • 3 posts

Posted 23 May 2014 - 04:54 PM

Hello I'm very new to CC and Coding in general. I've searched for topics on multiple menus but I don't understand the help that is being given in them.

I'm writing code to control and automate a nuclear reactor and it's fueling.
I'm trying to use a menu with sub menu's.

As it stands what my code does is, when the enter key is pressed on "reactor" it clears the screen and prints the second table but omits option 1 starting at "Output Level" instead of "Temperature". On top of that on any arrow key press it returns back to the main menu. The Caveat is that on the second menu I can navigate it by pressing the down key, then pressing enter on reactor, and it will show me as being on the next item down for the second menu.

I've been staring at this code for about 12 hours now trying to do different things and I'm not sure what's going on. I know it's very messy. It used to be very different.

I've added Completely separate Variables to the second menu function. But it performs the same.

I think the issue is that it's trying to run both the MainMenu and RCmainMenu loops. however, when I put a break into the MainMenu it just tells me that there is supposed to be an "end".

Spoiler


#2 wieselkatze

  • Members
  • 221 posts
  • LocationGermany

Posted 23 May 2014 - 06:05 PM

I've not looked at all of the code, but the first thing that stands out is the "os1.pullEvent("keyRC")".

Firstly there isn't os1.pullEvent(), I think you meant os.pullEvent, because you haven't defined os1 before.

Secondly the name of the event is "key", not "keyRC".

So, change the "os1.pullEvent("keyRC")" to "os.pullEvent("key")" and reply if there are still problems.

#3 Draedo

  • Members
  • 3 posts

Posted 23 May 2014 - 06:11 PM

I did what you suggested and it returns a nil at line 58.
http://pastebin.com/PpPBGFvJ

function onItemSelected( menu )
 menu[selectedItem].handler()
end


#4 wieselkatze

  • Members
  • 221 posts
  • LocationGermany

Posted 23 May 2014 - 06:28 PM

Ok, I think I got it fixed now.
You declared RCMenuMain after you called it.
So you have you main function properly working, but if you select the first item, it calls RCMenuMain, which is currently not even defined yet.
Also in your onKeyPressesRC function you have to replace keysRC.enter, keysRC.up and keysRC.down with keys.enter and so on.
If you've done that, move the whole part from line 73 to line 203 up (above) choice1().
Also just delete line 205.

Fixed code could look like this:
http://pastebin.com/pZDKJp6c

~wieselkatze

#5 Draedo

  • Members
  • 3 posts

Posted 23 May 2014 - 07:07 PM

Thanks dude! That works,. after staring at it for hours on end with no results this is a huge sigh of relief.

though I just keep thinking to myself, there has to be a simpler way but this will work for now.

I'll keep in mind defining something BEFORE you call it.

If you have any other advice i'm all ears. Thanks again!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users