Add safemove
This commit is contained in:
parent
4ea3db4197
commit
f44f4163a8
@ -124,7 +124,6 @@ function digShaft()
|
|||||||
digDeep(turtle.down, noop, noop, depth)
|
digDeep(turtle.down, noop, noop, depth)
|
||||||
turtle.turnLeft()
|
turtle.turnLeft()
|
||||||
digDeep(turtle.up, noop, noop, depth)
|
digDeep(turtle.up, noop, noop, depth)
|
||||||
turtle.turnLeft()
|
|
||||||
selectCobble()
|
selectCobble()
|
||||||
turtle.placeDown()
|
turtle.placeDown()
|
||||||
turtle.up()
|
turtle.up()
|
||||||
@ -132,9 +131,80 @@ function digShaft()
|
|||||||
turtle.up()
|
turtle.up()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function digTo(x, z)
|
||||||
|
print("Digging to rel. coord ("..tostring(x)..", "..tostring(z)..")")
|
||||||
|
while z > 0 do
|
||||||
|
turtle.dig()
|
||||||
|
turtle.forward()
|
||||||
|
turtle.digUp()
|
||||||
|
z = z - 1
|
||||||
|
end
|
||||||
|
turtle.turnRight()
|
||||||
|
while x > 0 do
|
||||||
|
turtle.dig()
|
||||||
|
turtle.forward()
|
||||||
|
turtle.digUp()
|
||||||
|
x = x - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- move safely into the direction, not hurting other turtles, but freeing the path if needed.
|
||||||
|
function moveSafe(moveAction, inspectAction, digAction)
|
||||||
|
while true do
|
||||||
|
local status, block = inspectAction()
|
||||||
|
if status then
|
||||||
|
if block["name"]:lower():find("turtle") then
|
||||||
|
-- turtle in front of me. lets wait for it to move
|
||||||
|
sleep(0.6)
|
||||||
|
else
|
||||||
|
digAction()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- nothing in the way, try to move
|
||||||
|
if moveAction() then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function goToSpawn(x, z)
|
||||||
|
turtle.digUp()
|
||||||
|
turtle.up()
|
||||||
|
while z > 0 do
|
||||||
|
moveSafe(turtle.forward, turtle.inspect, turtle.dig)
|
||||||
|
z = z - 1
|
||||||
|
end
|
||||||
|
turtle.turnRight()
|
||||||
|
while x > 0 do
|
||||||
|
moveSafe(turtle.forward, turtle.inspect, turtle.dig)
|
||||||
|
x = x - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function goToBarrel()
|
||||||
|
moveSafe(turtle.forward, turtle.inspect, noop)
|
||||||
|
turtle.turnRight()
|
||||||
|
moveSafe(turtle.forward, turtle.inspect, noop)
|
||||||
|
turtle.turnLeft()
|
||||||
|
moveSafe(turtle.forward, turtle.inspect, noop)
|
||||||
|
moveSafe(turtle.forward, turtle.inspect, noop)
|
||||||
|
moveSafe(turtle.forward, turtle.inspect, noop)
|
||||||
|
moveSafe(turtle.down, turtle.inspectDown, noop)
|
||||||
|
turtle.turnLeft()
|
||||||
|
end
|
||||||
|
|
||||||
|
function emptyToBarrel()
|
||||||
|
end
|
||||||
|
|
||||||
spotNum = tonumber(args[1])
|
spotNum = tonumber(args[1])
|
||||||
if spotNum then
|
if spotNum then
|
||||||
x, z = ithSpot(spotNum)
|
x, z = ithSpot(spotNum)
|
||||||
digTo(x,z)
|
digTo(x,z)
|
||||||
digShaft()
|
digShaft()
|
||||||
|
--goToSpawn(x, z)
|
||||||
|
--goToBarrel()
|
||||||
|
--emptyToBarrel()
|
||||||
end
|
end
|
||||||
|
--moveSafe(turtle.forward, turtle.inspect, turtle.dig)
|
||||||
|
--moveSafe(turtle.forward, turtle.inspect, turtle.dig)
|
||||||
|
Loading…
Reference in New Issue
Block a user