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

Tunnel Mining Turtle: Avoiding diamond

Started by xizors, 20 April 2013 - 07:37 AM
xizors #1
Posted 20 April 2013 - 09:37 AM
Hi! :)/>

Im trying to either program or find a turtle that is able to avoid mining diamonds, and then keep mining my tunnel. (Or just stops mining).

The tunnel has to be 3x3, place torches, refuel automaticly, and maybe put the stuff it got in a chest.


This is what i've got so far:


    function digIt()
	  while turtle.detect() do
	    turtle.dig()
	    os.sleep(0.5)
	  end
	  turtle.forward()
	  while turtle.detectDown() or turtle.detectUp() do
	    turtle.digUp()
	    turtle.digDown()
	  end
    end
	
    function placeTorch()
	  turtle.select(16)
	  turtle.placeUp()
    end
	
    local run = 0
    term.write("Tunnel length: ")
    run = read()
	
    for i = 1, run do
	  k = i - 1
	  j = k % 4
	  digIt()
	  turtle.turnLeft()
	  digIt()
	  turtle.turnRight()
	  turtle.turnRight()
	  turtle.forward()
	  digIt()
	  turtle.back()
	  turtle.turnLeft()
	  if i == 2 or j == 1 then
	    turtle.back()
	    turtle.turnRight()
	    turtle.forward()
	    placeTorch()
	    turtle.back()
	    turtle.back()
	    placeTorch()
	    turtle.forward()
	    turtle.turnLeft()
	    turtle.forward()
	  end
    end



Thanks in advance! :D/>
Bubba #2
Posted 20 April 2013 - 10:46 AM
Have you looked into turtle.compare()? Currently, the only way to identify diamond ore without digging it is by comparing each block to a diamond block that you have in your inventory, which I suppose you could cheat in or use silk touch to get.

Is the reason that you want it to stop that you have fortune enchanted on a pickaxe?
xizors #3
Posted 20 April 2013 - 12:01 PM
Have you looked into turtle.compare()? Currently, the only way to identify diamond ore without digging it is by comparing each block to a diamond block that you have in your inventory, which I suppose you could cheat in or use silk touch to get.

Is the reason that you want it to stop that you have fortune enchanted on a pickaxe?

Yeah, I want to use an enchanted pickaxe on it. But im pretty bad at coding, so yeah, it will be a hastle. :wacko:/>
Bubba #4
Posted 20 April 2013 - 12:27 PM
Have you looked into turtle.compare()? Currently, the only way to identify diamond ore without digging it is by comparing each block to a diamond block that you have in your inventory, which I suppose you could cheat in or use silk touch to get.

Is the reason that you want it to stop that you have fortune enchanted on a pickaxe?

Yeah, I want to use an enchanted pickaxe on it. But im pretty bad at coding, so yeah, it will be a hastle. :wacko:/>

To be honest, it'll be faster if you have the turtle just mine the diamond and cover a wider area in the time that you would have to go to the area with the diamond. But if you're really set on doing it this way, give something like this a shot:

--[[

For the sake of speed, put the diamond block into the first slot.

That way, you won''t have to reselect the first slot every time you compare blocks.

With the first slot selected, items will automatically go to the first available slot.
]]
turtle.select(1)
while not turtle.compare() do
  while turtle.dig() do end --This will continue digging if there is gravel in front of it
  turtle.forward()
  if turtle.compareUp() then
	break
  end
  while turtle.digUp() do end
end