All been working smoothly so far.
Mining Turtle code V6
Code:
function mForward()
while not turtle.forward() do
turtle.dig()
end
end
local tArgs = {...}
if #tArgs ~= 3 then
print("Requires length, width, height")
return
end
local x = tonumber(tArgs[1]) - 1
local y = tonumber(tArgs[2])
local z = tonumber(tArgs[3])
if x == nil or y == nil or z == nil then
print("Invalid dimensions")
return
end
if x < 0 or y < 0 or z < 0 then
print("Invalid (negative) dimensions")
return
end
local fuel = turtle.getFuelLevel()
local roomSize = (x * y * z) + 100
while fuel < roomSize do
if not turtle.refuel(1) then
print("Not enough fuel")
return
end
fuel = turtle.getFuelLevel()
end
local direction = true
for i = 1, z do
for j = 1, y do
for k = 1, x do
turtle.dig()
mForward()
end
if y ~= 1 then
if j < y then
if direction then
turtle.turnRight()
turtle.dig()
mForward()
turtle.turnRight()
direction = false
else
turtle.turnLeft()
turtle.dig()
mForward()
turtle.turnLeft()
direction = true
end
end
end
end
if i < z then
turtle.digUp()
while not turtle.up() do
turtle.digUp()
end
turtle.turnRight()
turtle.turnRight()
end
end
if z % 2 ~= 0 then
if y % 2 == 0 then
turtle.turnRight()
for i = 1, y do
mForward()
end
turtle.turnRight()
else
turtle.turnLeft()
for i = 1, y - 1 do
mForward()
end
turtle.turnLeft()
for i = 1, x do
mForward()
end
end
end
turtle.turnRight()
turtle.turnRight()
for i = 1, z - 1 do
turtle.down()
end