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

attempt to call nil

Started by Zephir, 22 June 2015 - 06:04 PM
Zephir #1
Posted 22 June 2015 - 08:04 PM
Hi i have a Problem with my MiningTurtle.
I Want to make a easy Programm to Mining a 3x10x4 tunnel.
but after he Breake the first String, it say: Zephir2:20: attempt to call nil
can anyone help me
This is my program:

for Start=1,2 do
turtle.dig()
turtle.forward()
turtle.turnRight()
for Mining=4,9 do
turtle.dig()
turtle.forward()
end
turtle.digUp()
turtle.turnLeft()
turtle.turnLeft()
turtle.up()
for Mining2=12,9 do
turtle.dig()
turtle.forward()
end
turtle.digUp()
turtle.turnRight()
turtle.turnRight()
turtle.Up()
for Mining3=20,9 do
turtle.dig()
turtle.forward()
end
turtle.turnLeft()
turtle.dig()
turtle.turnLeft()
for Mining4=27,9 do
turtle.dig()
turtle.forward()
end
turtle.digDown()
turtle.turnRight()
turtle.turnRight()
turtle.Down()
for Mining5=35,9 do
turtle.dig()
turtle.forward()
end
turtle.digDown()
turtle.turnLeft()
turtle.turnLeft()
turtle.Down()
for Mining6=43,9 do
turtle.dig()
turtle.forward()
end
turtle.turnRight()
end
HPWebcamAble #2
Posted 23 June 2015 - 06:45 AM
Luckily (Or not - You could likely figured this out!), this is just a small typo

Line 20:

turtle.Up()

Lua is case-sensitive so 'turtle.up()' (which is the correct function call) is different than 'turtle.Up()'
Edited on 23 June 2015 - 04:46 AM
Zephir #3
Posted 23 June 2015 - 05:42 PM
Thank you. Now it`s work ..
Zephir #4
Posted 23 June 2015 - 05:53 PM
I now have modified and it`s work pretty good.

But can you say me what say the first Number by starting a loop? (e.g. for Mining=5,9 do)
Edited on 23 June 2015 - 05:14 PM
MKlegoman357 #5
Posted 23 June 2015 - 07:20 PM
The loop:


for mining = 5, 9 do
  --# code
end

Will loop five times: 5, 6, 7, 8, 9. So the first number would be 5.
HPWebcamAble #6
Posted 24 June 2015 - 12:43 AM
SpoilerThe loop:


for mining = 5, 9 do
  --# code
end

Will loop five times: 5, 6, 7, 8, 9. So the first number would be 5.
Not QUITE sure if thats what he was asking though you could be correct

In a for-loop like this:

for m = 5, 9 do
  --# stuff
end

'm' starts at 5, and goes until 9. Optionally, you can add a third argument:

for m = 5, 9, 2 do

end
The third number is how many to increment by, so it would go

5 , 7 , 9