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

Turtle Help

Started by pHUNTERq, 25 February 2012 - 03:37 AM
pHUNTERq #1
Posted 25 February 2012 - 04:37 AM
I'm trying to make a program for my turtle to make it mine, and the program asks me for the depth, so I put it in, it digs down, moves down, digs forward, then I get this error: miner:7: attempt to call nil.

Here's my code:


write("Depth: ")
depth = read()


local function mineForward(blocks)
for counter=0, blocks, 1 do
  turtle.dig()
  turtle.Forward()
end
end

for counter=0, depth, 1 do
turtle.digDown()
turtle.down()
mineForward(6)
turtle.turnRight()
turtle.dig()
turtle.Forward()
turtle.turnRight()
mineForward(6)
turtle.turnRight()
turtle.dig()
turtle.Forward()
turtle.turnRight()
end

for counter=0, depth, 1 do
turtle.up()
end

Also, I'm pretty new at lua coding, so forgive me for any rookie errors :P/>/>
Espen #2
Posted 25 February 2012 - 05:01 AM
"Attempt to call nil" means it can't find the function you're trying to call.
It's trying to call …
turtle.Forward() 
… which doesn't exist. You probably just mistyped, it's actually …
turtle.forward() 

For this kind of error, as well as other common ones, take a look at this: http://www.computercraft.info/forums2/index.php?/topic/118-codex-of-error-slaying-2/
Edited on 25 February 2012 - 04:02 AM
pHUNTERq #3
Posted 25 February 2012 - 05:03 AM
Ahh, it was that easy! Well, thanks for finding the problem for me.