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

[LUA] Turtle Branch Mining Help

Started by LikeableBump, 09 December 2012 - 04:10 AM
LikeableBump #1
Posted 09 December 2012 - 05:10 AM
I'm trying to make a program that will make my mining turtle dig 50 block long 1x2 passages, placing torches every 10 blocks,then returning to where it started. I have it working fine unless it encounters gravel, and that messes it up and the passages end up being shorter than they should be. Here's what I have so far, and I'm very sure it's messy and has all kinds of things wrong with it but it works. What would I need to change or add to make it go 50 blocks even if there's gravel in the way? Also any tips would be greatly appreciated as I have no experience whatsoever.

The torches are supposed to be in slot 1 and cobble or any other material in slot 2.


for i=1,5 do

for i=1,10 do

   turtle.select(2)
   turtle.detectDown()
	if false then
	 turtle.placeDown()
   end

   turtle.detect()
	if true then turtle.dig()
   end

   turtle.up()

   turtle.detect()
	 if true then turtle.dig()
   end

   turtle.down()
   turtle.forward()

end

turtle.back()
turtle.back()
turtle.select(1)
turtle.place()
turtle.up()
turtle.forward()
turtle.forward()
turtle.down()

end

turtle.up()

for i=1,50 do
turtle.back()
end

turtle.down()
Doyle3694 #2
Posted 09 December 2012 - 05:28 AM
change
turtle.detect()
		 if true then turtle.dig()
   end

to


while turtle.detect() do
   turtle.dig()
   sleep(0.2)
end

Another note, for further notice, if you call turtle.detect() out in the void, the return of it will get thrown away.
 if turtle.detect() then turtle.dig() end
would be better syntax
LikeableBump #3
Posted 09 December 2012 - 06:44 AM
change
turtle.detect()
		 if true then turtle.dig()
   end

to


while turtle.detect() do
   turtle.dig()
   sleep(0.2)
end

I did that and gravel still confuses it. When gravel falls in it's path it makes the loop count it, even if it doesn't move forward, and then the tunnels it digs aren't long enough. Thanks for the help though. :)/> Also I have this other quick question.


   turtle.select(2)
   turtle.detectDown()
	    if false then
		 turtle.placeDown()

This was supposed to select the cobble in the second slot of the inventory and place it down if there wasn't a block beneath it. However, that does not work.
Doyle3694 #4
Posted 09 December 2012 - 10:45 PM

if not turtle.detectDown() then
   turtle.select(2)
   turtle.placeDown()
end
Emma #5
Posted 10 December 2012 - 04:02 AM
You could possibly place gravel in slot 16 and ask the turtle to compare it to the block it is breaking, and if it returns true move it to the bottom of the mine , make it break it and keep it in a while until it returns false
LikeableBump #6
Posted 12 December 2012 - 04:18 PM
I got it to work. Pretty much re-wrote it after looking at some other turtle mining programs. http://pastebin.com/s3JSuJWW There's the program if anyone is interested. Thanks for the help. :D/>