4 posts
Posted 26 November 2012 - 08:18 AM
So iv just started playing with technic and i really lke the computer craft mod, my only issue is trying to get some of the programs to work.
My main problem program is this:
for j = 1, 6 do
turtle.dig()
turtle.forward()
turtle.digDown()
turtle.placeDown(1)
turtle.turnLeft()
turtle.turnLeft()
turtle.place(2)
turtle.turnLeft()
turtle.turnLeft()
end
in this program 1 is a block of TNT and 2 is a dirt block placed to fill in the tunnel behind the turtle
I saved this program as "mine" , but when i attempt to run is i get the error:
mine:3: attempt to index ? (a nil value)
What am i doing wrong?
Thanks for any help,
Asid
1688 posts
Location
'MURICA
Posted 26 November 2012 - 08:35 AM
I don't want to insult your intelligence by asking if you're actually using this program on a turtle, so I'll just ask whether or not you've overwritten turtle beforehand.
As in, anywhere in this script or in another, have you run any program that says "turtle = blah" in it?
4 posts
Posted 26 November 2012 - 08:46 AM
first use of this turtle (mining turtle), brand new world in creative so new diskdrive and floppy disk too. The only program written is the one in my first post.
On another n00b note i just realised the turtle had no fuel, after adding a fuel source still no luck :/
1688 posts
Location
'MURICA
Posted 26 November 2012 - 09:27 AM
I'm not sure if this is the problem, but your use of place and placeDown isn't fully right. The turtle has to select the slot, then place the item.
turtle.select(1)
turtle.placeDown()
...
turtle.select(2)
turtle.place()
4 posts
Posted 26 November 2012 - 09:56 AM
OK so iv edit3ed the code slightly so it only works if the turtle can't move up:
for j = 1, 6 do
turtle.up()
while false do
turtle.dig()
turtle.forward()
turtle.digDown()
turtle.select (1)
turtle.placeDown()
end
end
This time no errors show in the console, the program just does not seem to kick in.
Turtle has fuel, has a block above it, has an block in slot 1.
I must be missing something vital
1688 posts
Location
'MURICA
Posted 26 November 2012 - 10:03 AM
Instead of checking if it can move up, you should probably just use turtle.detectUp().
if turtle.detectUp() then
for j = 1, 6 do
turtle.dig()
turtle.forward()
turtle.digDown()
turtle.select (1)
turtle.placeDown()
end
end
4 posts
Posted 26 November 2012 - 10:15 AM
Nope still no luck, the turtle will do all the built in commands away from the diskdrive and next to it, so im guessing they are both fine.
the version of computercraft in my technic is 1.4 will that make any difference at all?
2005 posts
Posted 26 November 2012 - 02:29 PM
Not for any of these commands, no. But you are using a "while false do … end" loop. This loop will never execute and will always be skipped because false is never true.
Kindaro's code is a valid effort, but it only works if there isn't a block above your turtle.
Edited on 26 November 2012 - 01:31 PM
1688 posts
Location
'MURICA
Posted 26 November 2012 - 02:37 PM
Kindaro's code is a valid effort, but it only works if there isn't a block above your turtle.
noooooo :P/>