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

[turtles]need assistance with my automatic turtle miner

Started by The, 25 September 2012 - 11:06 PM
The #1
Posted 26 September 2012 - 01:06 AM
I'm writing a turtle program which I hope would go out and mine 50 blocks, turn around, come back the same distance, then drop its inventory and move the right turn and repeat. I will have a line of obsidian pipes to recieve the drops. I get,

while true do
local amountOfTimes = 50
for 1,amountOfTimes do
turtle.dig()
turtle.forward()
turtle.digUp()
end
turtle.turnRight()
turtle.turnRight()
end
local amount2 = 50
for 1,amount2 do
turtle.forward()
end
for i = 1,16
turtle.select(i)
turtle.drop
end
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
end
end

the error i'm getting is :15: '<name>' expected

the main thing i'm unsure about is how to do the loops, i.e, the ones with for and the ones which are turning it around.
Noodle #2
Posted 26 September 2012 - 01:15 AM
1: For 1 Needs to be for i = 1, amountOfTimes
2: turtle.drop needs to be turtle.drop()
3: You don't need 2 ends at the end of the code
4: break after turnRight()
amountOfTimes = 50
while true do
for i = 1,amountOfTimes do
turtle.dig()
turtle.forward()
turtle.digUp()
end
turtle.turnRight()
turtle.turnRight()
break
end
for i = 1,amountOfTimes do
turtle.forward()
end

for i = 1,16
turtle.select(i)
turtle.drop()
end

turtle.turnRight()
turtle.forward()
The #3
Posted 26 September 2012 - 01:22 AM
why do we use break? i've seen it before.
Noodle #4
Posted 26 September 2012 - 01:26 AM
while true do
break
end

It "breaks" the loop.
Stops it, gets rid of it.

It's used for functions like reading
while true do
  input = read()
  if input == "poop" then
    break
  end
end
os.reboot() -- When it breaks the loop it resumes the program
That would reboot if you typed poop.
The #5
Posted 26 September 2012 - 01:46 AM
The fixes for the turtle work up when it must drop the items, it says :19: attempt to call nil. I believe this is because it tries to drop in an inventory space where no items are present. what must be done?