14 posts
Posted 02 February 2013 - 06:41 AM
[Lua][Error] attempt to index ? (a nil value)
I'm trying my hand at getting a turtle to build a structure for me - once I've got it working I'm going to use it to build a base under the surface of lava. Unfortunately, I keep getting that error. Here's a link to pastebin - I've imported it directly to the turtle using the pastebin command. And yes, it's defintiely a turtle not a computer.
http://pastebin.com/VvVPPhMF
309 posts
Location
Sliding between sunbeams
Posted 02 February 2013 - 06:46 AM
do sleep(0.1) instead of sleep 0.1
that should fix it
14 posts
Posted 02 February 2013 - 07:10 AM
Nope, still giving exactly the same error.
New file (I only just made a pastebin account):
http://pastebin.com/S1HwYeRt
2088 posts
Location
South Africa
Posted 02 February 2013 - 09:52 AM
Can you at least tell us which line?!
109 posts
Posted 02 February 2013 - 11:27 AM
Nope, still giving exactly the same error.
New file (I only just made a pastebin account):
http://pastebin.com/S1HwYeRt
Using this code I get no errors. Try rebooting minecraft (server and client). Sometimes things get jumbled up in there.
10 posts
Location
australia
Posted 02 February 2013 - 11:06 PM
you should get a error [number] attempt to index a nul value what is the number if possible could you please tell then maybe people can help more as opposed to trying to look through the whole code to find the error.
120 posts
Posted 02 February 2013 - 11:22 PM
unless you are setting turtle.right to turtle.turnRight ( as well as the lefts ) then that would be the biggest problem
6 posts
Location
England
Posted 03 February 2013 - 12:15 AM
Your whole program is wrapped in a function but the function is never called, How are you executing the program?
14 posts
Posted 03 February 2013 - 01:20 AM
Can you at least tell us which line?!
Oh, sorry - line 1
Your whole program is wrapped in a function but the function is never called, How are you executing the program?
>pastebin get S1HwYeRt basetest
>lua
>basetest.buildBase()
2088 posts
Location
South Africa
Posted 03 February 2013 - 01:27 AM
you need to do os.loadAPI("basetest") first before using it as an API.
14 posts
Posted 03 February 2013 - 03:48 AM
What exactly is an API, and how are you supposed to run programs if that's not it?
2088 posts
Location
South Africa
Posted 03 February 2013 - 06:21 AM
An
API is not meant to be the
main program. An API is a program but, it
ONLY contains functions for future use when you load it from another program.
People would use it to make their main program 'neater' if the functions within the API are not needed to be edited to suit the programs needs.
Example:
Make a program and call it 'myAPI' in the computers main folder.
Open it and add this to it:
function hello()
print("Hello there! Do i know you?")
end
Now you main program have this:
os.loadAPI("myAPI")
print("Line")
myAPI.hello()
print("You should know me :(/>")
Output:
Line
Hello there! Do i know you?
You show know me :(/>
Now it called the functions from the API and ran it.
14 posts
Posted 03 February 2013 - 07:09 AM
So I should take out the function wrapper, and then just calling basetest will work?
Yep, that worked. Thanks for the help, all!