Posted 16 February 2015 - 06:25 PM
this is my first script. i have very little programming experience, mostly html. i want it to dig a 3x3 tunnel. so far it works pretty great. until it encounters an empty block, then it keeps going in that direction messing up its pattern. any suggestions?
digAll() is for gravel/sand
distance is divided in half because it makes two passes. left to right, then right to left. this is to minimize movement as much as possible to conserve fuel.
local run = 0
term.write("Distance? ")
run = read() / 2
function digAll()
while turtle.detect() do
turtle.dig()
sleep(0.5)
end
end
function digForward()
digAll()
turtle.forward()
turtle.digUp()
turtle.digDown()
end
function layerA()
digForward()
turtle.turnLeft()
digForward()
turtle.forward()
digForward()
turtle.turnRight()
end
function layerB()
digForward()
turtle.turnRight()
digForward()
turtle.forward()
digForward()
turtle.turnLeft()
end
for i = 1, run do
layerA()
layerB()
end
digAll() is for gravel/sand
distance is divided in half because it makes two passes. left to right, then right to left. this is to minimize movement as much as possible to conserve fuel.