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

Error: lua:1: attempt to index ? (a nil value)

Started by LapizNinja, 08 March 2014 - 10:18 PM
LapizNinja #1
Posted 08 March 2014 - 11:18 PM
OK, so I have written my own API named Nico.lua that is located in the folder .technic>modpacks>tekkit>mods>ComputerCraft>lua>rom>apis

(Yes, I am using the modpack tekkit classic which includes computer craft and is running on minecraft version 1.2.5 but i dont know what computer craft version is inculded in tekkit classic)

Now here is what I type in my mining turtle (red is what is actually typed while ">" indicates i hit the enter key): lua>Nico.dig

Now after trying to activate the dig function in my API named Nico.lua I run into this error message over and over again: lua:1: attempt to index ? (a nil value)

Here is what my function is supposed to make the mining turtle do: The turtle is supposed to mine a straight row of ground until it detects there is no more blocks in its path, then it will turn right, move foward, and turn right again to mine another row down the opposite way to complete the proccess.

I have tryed two different ways to code this specific function which will both be included in the pastebin link I provide and both of them have been getting the same error message. I am hoping that you will be able to tell me which version I should use. Please help by telling me what I need to change or pasting my code back with the areas that you have changed in it colored in red. I also hope that the error message will be explained so that if it happens again I can locate what i did wrong and fix the error it is trying to tell me.
Thanks!

Pastebin: http://pastebin.com/6NdZjDQ0
CometWolf #2
Posted 09 March 2014 - 01:44 AM
Remove .lua from the file name. When you use variable.whatever, lua considers it the same as variable["whatever"], and therefore won't be able to acess your api properly. Also, you have to spell the full api name obviously. And im assuming this is on single player?
LapizNinja #3
Posted 09 March 2014 - 03:19 AM
Remove .lua from the file name. When you use variable.whatever, lua considers it the same as variable["whatever"], and therefore won't be able to acess your api properly. Also, you have to spell the full api name obviously. And im assuming this is on single player?

I removed the .lua from the name and still got the same error, also this is on my private multiplayer tekkit server.
theoriginalbit #4
Posted 09 March 2014 - 05:25 AM
you missed the braces at the end of your function name. example function definition


function name( args ) --# arg variable names are optional
  --# code here
end
LapizNinja #5
Posted 09 March 2014 - 12:12 PM
Nope, same error. Thanks anyways for helping.