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

All Commands Return A "Nil" Error

Started by Icyboom15, 20 December 2012 - 04:42 PM
Icyboom15 #1
Posted 20 December 2012 - 05:42 PM
I am a beginner to Lua scripting, but through youtube tutorials, I understand the basics. I made a program almost identical to this on CC 1.3 (Tekkit, mind you), and it worked flawlessly. I remade the program on 1.4, and no matter what I do, I keep getting a nil error. I think I understand what a nil error is, but obviously have no idea how to fix it. XD


I have pictures relating to the error and my code, so any and all help would be appreciated!!!


[attachment=797:Tekkit MineHall Nil Error 1.jpg]

[attachment=798:Tekkit MineHall Nil Error 2.jpg]

(I am probably overlooking things very miniscule…. >:/ )
theoriginalbit #2
Posted 20 December 2012 - 05:44 PM
the "nil error" is because you are trying to call something that doesn't exist. Note that in the error it says 7. that means the error is on line 7. if we look at line 7 we notice that you are trying to pass a parameter to turtle.dig() when it doesn't want one (none of them do), so Lua is trying to call a function that doesn't exist, hence nil.

EDIT: Use this http://computercraft...iki/Turtle_(API) to fix up all your turtle. function calls :)/>

EDIT #2: Also due to the cause of the error I don't see how this worked on CC 1.3.
Icyboom15 #3
Posted 20 December 2012 - 05:46 PM
.Okay, so then what would I do to get the turtle to perform the desired task?

EDIT: Okay, I get that, but I still don't understand how to get it to perform the task if I put both turtle.dig(1) and turtle.dig() and both returned a nil error. Any help is appreciated, haha.
theoriginalbit #4
Posted 20 December 2012 - 05:47 PM
remove the parameter from the function call. See my first edit :)/>
Icyboom15 #5
Posted 20 December 2012 - 05:49 PM
By parameter, you mean the (1)? Like I said, a beginner at Lua, and programming in general, Hahaha sorry for being such a nuisance..
theoriginalbit #6
Posted 20 December 2012 - 05:51 PM
By parameter, you mean the (1)? Like I said, a beginner at Lua, and programming in general, Hahaha sorry for being such a nuisance..

Thats ok, yes i mean the 1 inside the brackets. Anything inside the brackets of a function call is called a parameter. :)/>

EDIT: The ( ) must stay there though. only remove the number!
ChunLing #7
Posted 20 December 2012 - 05:53 PM
Post your revised code (feel free to post text in code tags, rather than an image) and the current error you are getting.
Lyqyd #8
Posted 20 December 2012 - 06:15 PM
the "nil error" is because you are trying to call something that doesn't exist. Note that in the error it says 7. that means the error is on line 7. if we look at line 7 we notice that you are trying to pass a parameter to turtle.dig() when it doesn't want one (none of them do), so Lua is trying to call a function that doesn't exist, hence nil.

The presence of an unnecessary parameter doesn't somehow magically cause the function to not exist, the function simply ignores the parameter.

OP, please try running this code on a turtle. If I recall correctly, the screenshots are of screens too large to be turtle screens. The turtle API itself is unavailable on computers (it's only present on turtles), so if course, any function you tried to use from it would be an attempt to index the table "turtle", which is nil, resulting in the error message, "attempt to index ? (a nil value)".