This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
raysilverstone's profile picture

Function Not working?

Started by raysilverstone, 30 November 2013 - 08:23 PM
raysilverstone #1
Posted 30 November 2013 - 09:23 PM
I'm trying to learn Lua and I think I have a basic understanding so far. My Problem is that I can't figure out why my program is giving this error. I've traced back the function and it all seems right. I've modified a tunnel program to make paths. I used some of the code made by HuskyBlueFire. Any help would be great. When I run the program it gives me this error:
DiggyPath:652: attempt to call nil
Here is the pastebin link to my code.
http://pastebin.com/dMXRtGtm
Bomb Bloke #2
Posted 30 November 2013 - 10:36 PM
Notice how the "moveForward()" and "moveBack()" functions are both missing an "end", but "removeXChest()" and "removeIChest()" have an extra one each?

This means that the bulk of your function declarations are inside the "moveForward()" function. As far as Lua is concerned, those encapsulated functions don't exist until that function has been called (which causes it to process those extra declarations).

Anyhow, move those "end"s and give it another shot.