TheKojent icon

clear

TheKojent | PRO | 02/01/13 03:20:06 AM UTC | 0 ⭐ | 210 👁️ | Never ⏰ | []
Lua |

1.24 KB

|

None

|

0 👍

/

0 👎

--First attempt at excavation program
function dumpInv() --Dumps inventory into ender chest located in slot 1
  turtle.digUp()
  turtle.select(1)
  turtle.placeUp()
  for i = 1,15 do
    i = i + 1
    turtle.dropUp()
  end
  turtle.select(1)
  turtle.digUp()
end
 
function checkInv()
  if turtle.getItemCount(16) ~= 0 then
    dumpInv()
  end
end
  
function digFwd()
  while turtle.forward() == false do
    turtle.dig()
  end
end  
 
function digRow()
  turtle.select(1)
  for l = 1,(x-1) do
    checkInv()
    digFwd()
  end
end
 
--Main function
print("Enter even length")
x = io.read()
x = tonumber(x)
print("Enter even width")
y = io.read()
y = tonumber(y)
print("Enter even depth")
z = io.read()
z = tonumber(z)
fuelreq = x * y * z --Checking fuel level
if turtle.getFuelLevel() < fuelreq then
  print("Not enough fuel...rebooting")
  os.sleep(10)
  os.reboot()
end
for h = 1,z do
  for w = 1,((y/2)-1) do
    digRow()
    turtle.turnRight()
    digFwd()
    turtle.turnRight()
    digRow()
    turtle.turnLeft()
    digFwd()
    turtle.turnLeft()
  end
  digRow()
  turtle.turnRight()
  digFwd()
  turtle.turnRight()
  digRow()
  while turtle.down == false do
    turtle.digDown()
  end
  turtle.turnRight()
end
dumpInv()

Comments