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

Errors in turtles program?

Started by tdlab, 13 August 2012 - 01:03 PM
tdlab #1
Posted 13 August 2012 - 03:03 PM
Hey everyone, tdlab here again with another problem :P/>/> Here i'm trying this code i found on the wiki. (The advanced cobble gen) I put in this code in a pastebin if you cant figure out what code im talking about http://pastebin.com/sjFniERU . Could anyone help me why i get this error on my turtle
startup:27: attempt to call nil

Thanks once again guys!
Cranium #2
Posted 13 August 2012 - 03:30 PM
I believe it's the line 3 trying to return function(), which is not stated. Are you trying to have that function "=" something? You may want the return to be something else.

function counter()
local i = 0
i = i + 1
return i
end
Kazimir #3
Posted 13 August 2012 - 03:31 PM
Error on startup? I have this code works, maybe you copied the wrong?
I keep through Notepad++ with syntax highlighting Lua
Grim Reaper #4
Posted 13 August 2012 - 05:03 PM
I think that the error may be occurring in the same spot that cranium kid had pointed out, but it's not because you're returning a function.

The error may be occurring because the identifier 'i' is not defined within the function that you are returning, but it is defined with the local access specifier; so when you return the function 'i' is nil.

I am not entirely sure, however. I have been away from LUA for some time and therefore you should refer to another reference book or someone who has the same code working.
tdlab #5
Posted 13 August 2012 - 08:11 PM
I'm not very familiar with cc coding and am using this code to kinda get the idea of how it works, but since I didn't code this program I'm not entirely sure how it works