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

turtle that handels bedrock?

Started by jakemg, 13 June 2013 - 09:53 PM
jakemg #1
Posted 13 June 2013 - 11:53 PM
Hi Im trying to make turtle program where i have a long line of turtles and they all dig down to bed rock then then go forward and dig all the way down again. But I cant quite cant my turtle to recognize when they hit bedrock
what im using now

function down()
  while true do
  turtle.digDown()
  turtle.down()
   if turtle.down == false then
   print("bedrock")
   end
  end
end

but this isnt working at all because he wont stop his while true loop so he never prints bedrock
theoriginalbit #2
Posted 13 June 2013 - 11:57 PM
And it will never print that it is at bedrock because the function turtle.down always exists, and that is all you're checking.

This is how you would need to do it

local function down()
  while not turtle.down() do
    if turtle.detectDown() then --# it couldn't move because of a block
      if not turtle.digDown() then --# it couldn't dig a block, assume it is a diamond axe, and a the only thing that cannot be dug is bedrock.
        print("bedrock")
      end
    elseif turtle.attack() then --# it couldn't move because of a mob
      while turtle.attack() do end
    elseif turtle.getFuelLevel() == 0 then --# it couldn't move because of no fuel
      --# refuel it
    end
  end
end
jakemg #3
Posted 14 June 2013 - 02:14 PM
thanks