Posted 07 April 2014 - 07:24 AM
hi im working on a 3x3 tunnel miner with a turtle which was going fine until i ran into some gravel causing the program to glitch. i need to be able to compare the block before digging so that for dirt and gravel it will use the shove and wait after digging gravel to check for more gravel and so that all other blocks use the pick
shovel assigned to the right side and pick to the left side
my code (problem in dig(), digUp() and digDown() functions)
im using the turtle.compare() instead of the turtle.compareTo() because its not working correctly
pastebin link here
shovel assigned to the right side and pick to the left side
my code (problem in dig(), digUp() and digDown() functions)
im using the turtle.compare() instead of the turtle.compareTo() because its not working correctly
pastebin link here
function forward() turtle.forward() end
function up() turtle.up() end
function down() turtle.down() end
function left() turtle.turnLeft() end
function right() turtle.turnRight() end
function left2()
for
m = 1, 2, 1 do
left()
end
end
function right2()
for
m = 1, 2, 1 do
right()
end
end
function digDown()
if
turtle.detectDown() == true then
turtle.select(2)
if
turtle.compare() == true then
turtle.digDown(right)
elseif
turtle.select(3)
turtle.compareDown() == true then
turtle.digDown(right)
else
turtle.digDown(left)
end
end
end
function dig()
if
turtle.detect() == true then
turtle.select(2)
if
turtle.compare() == true then
turtle.dig(right)
elseif
turtle.select(3)
turtle.compare() == true then
turtle.dig(right)
else
turtle.dig(left)
end
end
end
function digUp()
if
turtle.detectUp() == true then
turtle.select(2)
if
turtle.compareUp() == true then
turtle.digUp(right)
elseif
turtle.select(3)
turtle.compare() == true then
turtle.digUp(right)
else
turtle.digUp(left)
end
end
end[/color]
function detectDown()
if
turtle.detectDown() == false then
turtle.select(1)
turtle.placeDown()
end
end
function detect()
if
turtle.detect() == false then
turtle.select(1)
turtle.place()
end
end
function detectUp()
if
turtle.detectUp() == false then
turtle.select(1)
turtle.placeUp()
end
end
dig()
--[[
-- left side of 3x3 tunnel
dig()
forward()
left()
detectDown()
detect()
digUp()
up()
detect()
digUp()
up()
detect()
detectUp()
right2()
-- top side of 3x3 tunnel
dig()
forward()
detectUp()
digDown()
dig()
forward()
detectUp()
detect()
-- right side of 3x3 tunnel
digDown()
down()
detect()
digDown()
down()
detect()
detectDown()
left2()
-- bottom side of 3x3 tunnel
dig()
forward()
detectDown()
forward()
right()
--]]
Edited on 07 April 2014 - 05:28 AM