computercraft program not working

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord
try changing "menu[selectedItem].handler()" on line 106 to "menu(selectedItem).handler()"
This is a straight up guess though, my lua is pretty terrible
 
You need to define menu in line 106. There is no function defined anywhere in your code called menu. However you are calling menu like it was a function.

EDIT: I've looked at your code some more. Looks like you are trying to use handles to call the various bridge functions. I've been searching however, I don't think LUA supports this. You might want to change lines 105 to 107 to something like this:

function onItemSelected( itemid )
if itemid == 1 then BridgeMenu()
if itemid == 2 then Config()

-- continue putting in cases

end

I think you will need to re-write your menu functions.
 
You need to define menu in line 106. There is no function defined anywhere in your code called menu. However you are calling menu like it was a function.

EDIT: I've looked at your code some more. Looks like you are trying to use handles to call the various bridge functions. I've been searching however, I don't think LUA supports this. You might want to change lines 105 to 107 to something like this:

function onItemSelected( itemid )
if itemid == 1 then BridgeMenu()
if itemid == 2 then Config()

-- continue putting in cases

end

I think you will need to re-write your menu functions.


i fixed the issue, it now runs the Bridge menu
this is what i changed:
this :
  1. mainMenu = {
  2. [1] = { text = "Bridge Control", handler = BridgeMenu },
  3. [2] = { text = "Config", handler = Config },
  4. [3] = { text = "Shutdown", handler = shutdown }
  5. }

to this:
  1. mainMenu = {
  2. [1] = { text = "Bridge Control", handler = Bridge },
  3. [2] = { text = "Config", handler = Config },
  4. [3] = { text = "Shutdown", handler = shutdown }
  5. }

but now it says: startup:124: attempt to index? (a nil value)
 
Line 123 is the issue. You are still trying to use a handle to call the functions. I don't think LUA supports this. I've been searching the official LUA documentation on this and can't find anything. I still think you need to re-write the code so that it doesn't use handles.
 
Line 123 is the issue. You are still trying to use a handle to call the functions. I don't think LUA supports this. I've been searching the official LUA documentation on this and can't find anything. I still think you need to re-write the code so that it doesn't use handles.

it is quite strange because on an other program it works and for that i used this youtube video:
so im a bit confused...

If you could help me with the code, that would be awesome, because i don't have very much nderstanding of lua..
 
OP, take a look at line 14. It looks like you meant to type "inBridgeMenu"

For your actual problem, I suspect what's happening is a conversion from int to string or vice-versa. Trying replacing the variable "selectedItem" with just the number 1 and see what happens.
 
I finally understand how this menu system works. Learned more about LUA in the process so that is cool :).

Anyway I found two major problems with your code. First, your functions must all be defined and coded before you reference them in the menu arrays (mainmenu & bridgemenu). In the case of the bridgemenu you were calling the array in the function before it was defined in code. So I forced a 2nd function call in the handlers area to B2(). Second in your bridge menu code (your line 20) you were referencing a menu that doesn't exist. You can get my edits of your code here: http://pastebin.com/QuKQjAhG

Good luck!

And snooder thanks the LUA reference. Most other languages refer to something like this as a handle. LUA doesn't use that term which is why I couldn't find it.
 
I finally understand how this menu system works. Learned more about LUA in the process so that is cool :).

Anyway I found two major problems with your code. First, your functions must all be defined and coded before you reference them in the menu arrays (mainmenu & bridgemenu). In the case of the bridgemenu you were calling the array in the function before it was defined in code. So I forced a 2nd function call in the handlers area to B2(). Second in your bridge menu code (your line 20) you were referencing a menu that doesn't exist. You can get my edits of your code here: http://pastebin.com/QuKQjAhG

Good luck!

And snooder thanks the LUA reference. Most other languages refer to something like this as a handle. LUA doesn't use that term which is why I couldn't find it.

Aha, I now understand, wrong order and now that I look at it again, at the beginning
Local inLockdownMenu = false doesn't make any sence....
However, Thanks alot and good(for you) that you learned more about LUA(if you ever want do something with it) ;-)