15 posts
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!
3790 posts
Location
Lincoln, Nebraska
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
90 posts
Location
that's no moon...
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
504 posts
Location
Seattle, WA
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.
15 posts
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