Skip to content

Instantly share code, notes, and snippets.

@zmbush
Last active December 25, 2015 07:19
Show Gist options
  • Save zmbush/6938431 to your computer and use it in GitHub Desktop.
Save zmbush/6938431 to your computer and use it in GitHub Desktop.
Turtle Scripts
function fuel_up()
while turtle.getFuelLevel() == 0 do
turtle.select(1)
turtle.refuel(1)
end
end
function safe_forward()
fuel_up()
while not turtle.forward() do
end
end
function safe_back()
fuel_up()
while not turtle.back() do
end
end
function safe_up()
fuel_up()
while not turtle.up() do
end
end
function safe_down()
fuel_up()
while not turtle.down() do
end
end
forward = 10
left = 10
blocksTotal = forward * left
blocksBroken = 0
x = 0
y = 0
direction = 1
while (x < forward or y < left) do
turtle.digUp()
turtle.digDown()
if direction == 1 then
if x < forward then
turtle.dig()
safe_forward()
x = x + 1
else
direction = 0
y = y + 1
turtle.turnLeft()
turtle.dig()
safe_forward()
turtle.turnLeft()
end
else
if x > 0 then
turtle.dig()
safe_forward()
x = x - 1
else
direction = 1
y = y + 1
turtle.turnRight()
turtle.dig()
safe_forward()
turtle.turnRight()
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment