58 posts
Posted 19 January 2013 - 08:09 PM
Okay so I am writing a program for having an elevator and then being able to select which floor to go to from that menu and i am getting an attempt to get length of nil on line 74 but i have no idea why and i've used code almost exactly like this before on 1.4.2 and it worked then so if you'd like to help here is the pastebin link to my code:
http://pastebin.com/bKpsdGch
7508 posts
Location
Australia
Posted 19 January 2013 - 08:16 PM
the problem is actually on line 75, its not liking the #menu… I just tested it and if you change all occurrences of menu in the functions printMenu and onKeyPressed with mainMenu it will work… This is because you are not actually passing it the reference to the table, you are passing reference to an unknown value ( its a typo ) "mainMain" instead of "mainMenu"
Edited on 19 January 2013 - 07:22 PM
58 posts
Posted 19 January 2013 - 08:19 PM
Alright thanks, like i've said i've used literally the exact same code before just with different names in the table and havent had a problem with it but whatever, thanks for the help
7508 posts
Location
Australia
Posted 19 January 2013 - 08:21 PM
Alright thanks, like i've said i've used literally the exact same code before just with different names in the table and havent had a problem with it but whatever, thanks for the help
You next error after fixing the typo will be because this function "onItemSelected" doesn't exist yet… but I'm sure you already know that :)/>
58 posts
Posted 19 January 2013 - 08:28 PM
the problem is actually on line 75, its not liking the #menu… I just tested it and if you change all occurrences of menu in the functions printMenu and onKeyPressed with mainMenu it will work… This is because you are not actually passing it the reference to the table, you are passing reference to an unknown value ( its a typo ) "mainMain" instead of "mainMenu"
so what should i do to fix it? just changing the menu's to mainMenus?
and as for the "onItemSelected" not existing I've used this code before so unless something changed it should be fine, but i may be wrong :P/> once i get this other problem fixed ill come back with the results
7508 posts
Location
Australia
Posted 19 January 2013 - 08:34 PM
so what should i do to fix it? just changing the menu's to mainMenus?
you are passing reference to an unknown value ( its a typo ) "mainMain" instead of "mainMenu"
and as for the "onItemSelected" not existing I've used this code before so unless something changed it should be fine, but i may be wrong :P/> once i get this other problem fixed ill come back with the results
I can tell you now its not gunna work, I tested the code you pastebined and there is not function "onItemSelected" in that code…
58 posts
Posted 19 January 2013 - 08:40 PM
I changed all the instances of menu to mainMenu and am still getting the same issue ( updated pastebin) Nevermind got it and then on the onItemSelected i forgot to bring over the function, silly me :P/> and i also found out what i did wrong with printing the table in the first place, for the ending lines in function main() where i call my function onKeyPressed i didnt pass mainMenu through, but instead passed menu making it not work
7508 posts
Location
Australia
Posted 19 January 2013 - 09:14 PM
I changed all the instances of menu to mainMenu and am still getting the same issue ( updated pastebin) Nevermind got it and then on the onItemSelected i forgot to bring over the function, silly me :P/> and i also found out what i did wrong with printing the table in the first place, for the ending lines in function main() where i call my function onKeyPressed i didnt pass mainMenu through, but instead passed menu making it not work
I knew you had forgot the function… the problem with printing was just the typo of mainMain instead of mainMenu… so all good now?